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