UNPKG

2.1 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/// <reference types="node" />
12
13declare module "klaw" {
14 import * as fs from "fs";
15 import { Readable, ReadableOptions } from "stream";
16
17 function K(root: string, options?: K.Options): K.Walker;
18
19 namespace K {
20 interface Item {
21 path: string;
22 stats: fs.Stats;
23 }
24
25 type QueueMethod = "shift" | "pop";
26
27 interface Options extends ReadableOptions {
28 queueMethod?: QueueMethod | undefined;
29 pathSorter?: ((pathA: string, pathB: string) => number) | undefined;
30 fs?: any; // fs or mock-fs
31 filter?: ((path: string) => boolean) | undefined;
32 depthLimit?: number | undefined;
33 preserveSymlinks?: boolean | undefined;
34 }
35
36 type Event = "close" | "data" | "end" | "error" | "pause" | "readable" | "resume";
37
38 interface Walker extends Readable, AsyncIterable<Item> {
39 on(event: Event, listener: Function): this;
40 on(event: "close", listener: () => void): this;
41 on(event: "data", listener: (item: Item) => void): this;
42 on(event: "end", listener: () => void): this;
43 on(event: "readable", listener: () => void): this;
44 on(event: "error", listener: (err: Error) => void): this;
45 read(): Item;
46 [Symbol.asyncIterator](): AsyncIterableIterator<Item>;
47 }
48 }
49
50 export = K;
51}
52
53````
54
55### Additional Details
56 * Last updated: Tue, 07 Nov 2023 20:08:00 GMT
57 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
58
59# Credits
60These definitions were written by [Matthew McEachen](https://github.com/mceachen), and [Pascal Sthamer](https://github.com/p4sca1).
61
\No newline at end of file