forked from mihneadb/node-directory-tree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
48 lines (41 loc) · 1.18 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Stats } from "fs";
interface IObj {
[key: string]: any;
}
declare function directoryTree<
TCustomFile extends IObj = IObj,
TCustomDir extends IObj = IObj,
TCustomResult = TCustomFile & TCustomDir
>(
path: string,
options?: directoryTree.DirectoryTreeOptions,
onEachFile?: directoryTree.DirectoryTreeCallback<TCustomFile>,
onEachDirectory?: directoryTree.DirectoryTreeCallback<TCustomDir>
): directoryTree.DirectoryTree<TCustomResult>;
export as namespace directoryTree;
declare namespace directoryTree {
export interface DirectoryTree<C extends IObj = IObj> {
path: string;
name: string;
size: number;
type: "directory" | "file";
children?: DirectoryTree<C>[];
extension?: string;
isSymbolicLink?: boolean;
custom: C;
}
export interface DirectoryTreeOptions {
normalizePath?: boolean;
exclude?: RegExp | RegExp[];
attributes?: (keyof Stats | "type" | "extension")[];
extensions?: RegExp;
followSymlinks?: boolean;
depth?: number;
}
export type DirectoryTreeCallback<TCustom extends IObj = IObj> = (
item: DirectoryTree<TCustom>,
path: string,
stats: Stats
) => void;
}
export = directoryTree;