UNPKG

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