UNPKG

1.7 kBTypeScriptView Raw
1// Type definitions for klaw v3.0.0
2// Project: https://github.com/jprichardson/node-klaw
3// Definitions by: Matthew McEachen <https://github.com/mceachen>
4// Pascal Sthamer <https://github.com/p4sca1>
5// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
7/// <reference types="node" />
8
9declare module "klaw" {
10 import * as fs from "fs";
11 import { Readable, ReadableOptions } from "stream";
12
13 function K(root: string, options?: K.Options): K.Walker;
14
15 namespace K {
16 interface Item {
17 path: string;
18 stats: fs.Stats;
19 }
20
21 type QueueMethod = "shift" | "pop";
22
23 interface Options extends ReadableOptions {
24 queueMethod?: QueueMethod | undefined;
25 pathSorter?: ((pathA: string, pathB: string) => number) | undefined;
26 fs?: any; // fs or mock-fs
27 filter?: ((path: string) => boolean) | undefined;
28 depthLimit?: number | undefined;
29 preserveSymlinks?: boolean | undefined;
30 }
31
32 type Event = "close" | "data" | "end" | "error" | "pause" | "readable" | "resume";
33
34 interface Walker extends Readable, AsyncIterable<Item> {
35 on(event: Event, listener: Function): this;
36 on(event: "close", listener: () => void): this;
37 on(event: "data", listener: (item: Item) => void): this;
38 on(event: "end", listener: () => void): this;
39 on(event: "readable", listener: () => void): this;
40 on(event: "error", listener: (err: Error) => void): this;
41 read(): Item;
42 [Symbol.asyncIterator](): AsyncIterableIterator<Item>;
43 }
44 }
45
46 export = K;
47}
48
\No newline at end of file