directory-tree 3.2.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.d.ts +30 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,7 +178,7 @@ const callback: DirectoryTreeCallback = (
|
|
|
178
178
|
item: DirectoryTree,
|
|
179
179
|
path: string
|
|
180
180
|
) => {
|
|
181
|
-
item.custom
|
|
181
|
+
item.custom = {id: createHash('sha1').update(path).digest('base64')};
|
|
182
182
|
};
|
|
183
183
|
|
|
184
184
|
const dirTree: DirectoryTree & { id?: string } = directoryTree(
|
package/index.d.ts
CHANGED
|
@@ -1,34 +1,48 @@
|
|
|
1
|
-
import { Stats } from
|
|
1
|
+
import { Stats } from "fs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface IObj {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare function directoryTree<
|
|
8
|
+
TCustomFile extends IObj = IObj,
|
|
9
|
+
TCustomDir extends IObj = IObj,
|
|
10
|
+
TCustomResult = TCustomFile & TCustomDir
|
|
11
|
+
>(
|
|
4
12
|
path: string,
|
|
5
|
-
options
|
|
6
|
-
onEachFile
|
|
7
|
-
onEachDirectory
|
|
8
|
-
): directoryTree.DirectoryTree
|
|
13
|
+
options?: directoryTree.DirectoryTreeOptions,
|
|
14
|
+
onEachFile?: directoryTree.DirectoryTreeCallback<TCustomFile>,
|
|
15
|
+
onEachDirectory?: directoryTree.DirectoryTreeCallback<TCustomDir>
|
|
16
|
+
): directoryTree.DirectoryTree<TCustomResult>;
|
|
9
17
|
|
|
10
18
|
export as namespace directoryTree;
|
|
11
19
|
|
|
12
20
|
declare namespace directoryTree {
|
|
13
|
-
export interface DirectoryTree {
|
|
21
|
+
export interface DirectoryTree<C extends IObj = IObj> {
|
|
14
22
|
path: string;
|
|
15
23
|
name: string;
|
|
16
24
|
size: number;
|
|
17
25
|
type: "directory" | "file";
|
|
18
|
-
children
|
|
26
|
+
children?: DirectoryTree<C>[];
|
|
19
27
|
extension?: string;
|
|
20
28
|
isSymbolicLink?: boolean;
|
|
21
|
-
custom:
|
|
29
|
+
custom: C;
|
|
22
30
|
}
|
|
31
|
+
|
|
23
32
|
export interface DirectoryTreeOptions {
|
|
24
|
-
normalizePath
|
|
25
|
-
exclude
|
|
26
|
-
attributes
|
|
27
|
-
extensions
|
|
28
|
-
followSymlinks
|
|
29
|
-
depth
|
|
33
|
+
normalizePath?: boolean;
|
|
34
|
+
exclude?: RegExp | RegExp[];
|
|
35
|
+
attributes?: (keyof Stats | "type" | "extension")[];
|
|
36
|
+
extensions?: RegExp;
|
|
37
|
+
followSymlinks?: boolean;
|
|
38
|
+
depth?: number;
|
|
30
39
|
}
|
|
31
|
-
|
|
40
|
+
|
|
41
|
+
export type DirectoryTreeCallback<TCustom extends IObj = IObj> = (
|
|
42
|
+
item: DirectoryTree<TCustom>,
|
|
43
|
+
path: string,
|
|
44
|
+
stats: Stats
|
|
45
|
+
) => void;
|
|
32
46
|
}
|
|
33
47
|
|
|
34
48
|
export = directoryTree;
|