UNPKG

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