-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathindex.d.ts
44 lines (38 loc) · 1.28 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
import { Stats } from "fs";
declare function directoryTree<
TCustomFile extends Record<string, any> = Record<string, any>,
TCustomDir extends Record<string, any> = Record<string, any>,
TCustomResult extends Record<string, any> = 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 Record<string, any> = Record<string, any>> {
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 Record<string, any> = Record<string, any>> = (
item: DirectoryTree<TCustom>,
path: string,
stats: Stats
) => void;
}
export = directoryTree;