UNPKG

2.38 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/klaw`
3
4# Summary
5This package contains type definitions for klaw (https://github.com/jprichardson/node-klaw).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/klaw.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/klaw/index.d.ts)
10````ts
11// Type definitions for klaw v3.0.0
12// Project: https://github.com/jprichardson/node-klaw
13// Definitions by: Matthew McEachen <https://github.com/mceachen>
14// Pascal Sthamer <https://github.com/p4sca1>
15// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
16
17/// <reference types="node" />
18
19declare module "klaw" {
20
21 import * as fs from "fs"
22 import { Readable, ReadableOptions } from 'stream'
23
24 function K(root: string, options?: K.Options): K.Walker
25
26 namespace K {
27 interface Item {
28 path: string
29 stats: fs.Stats
30 }
31
32 type QueueMethod = "shift" | "pop"
33
34 interface Options extends ReadableOptions {
35 queueMethod?: QueueMethod | undefined
36 pathSorter?: ((pathA: string, pathB: string) => number) | undefined
37 fs?: any // fs or mock-fs
38 filter?: ((path: string) => boolean) | undefined
39 depthLimit?: number | undefined
40 preserveSymlinks?: boolean | undefined
41 }
42
43 type Event = "close" | "data" | "end" | "error" | "pause" | "readable" | "resume"
44
45 interface Walker extends Readable, AsyncIterable<Item> {
46 on(event: Event, listener: Function): this
47 on(event: "close", listener: () => void): this
48 on(event: "data", listener: (item: Item) => void): this
49 on(event: "end", listener: () => void): this
50 on(event: "readable", listener: () => void): this
51 on(event: "error", listener: (err: Error) => void): this
52 read(): Item
53 [Symbol.asyncIterator](): AsyncIterableIterator<Item>
54 }
55 }
56
57 export = K
58}
59
60````
61
62### Additional Details
63 * Last updated: Wed, 20 Oct 2021 15:31:23 GMT
64 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
65 * Global values: none
66
67# Credits
68These definitions were written by [Matthew McEachen](https://github.com/mceachen), and [Pascal Sthamer](https://github.com/p4sca1).
69
\No newline at end of file