directory-tree
Advanced tools
Comparing version
@@ -1,9 +0,17 @@ | ||
import { Stats } from 'fs'; | ||
import { Stats } from "fs"; | ||
declare function directoryTree( | ||
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, | ||
onEachDirectory ? : directoryTree.DirectoryTreeCallback, | ||
): directoryTree.DirectoryTree; | ||
options?: directoryTree.DirectoryTreeOptions, | ||
onEachFile?: directoryTree.DirectoryTreeCallback<TCustomFile>, | ||
onEachDirectory?: directoryTree.DirectoryTreeCallback<TCustomDir> | ||
): directoryTree.DirectoryTree<TCustomResult>; | ||
@@ -13,3 +21,3 @@ export as namespace directoryTree; | ||
declare namespace directoryTree { | ||
export interface DirectoryTree { | ||
export interface DirectoryTree<C extends IObj = IObj> { | ||
path: string; | ||
@@ -19,18 +27,24 @@ name: string; | ||
type: "directory" | "file"; | ||
children ? : DirectoryTree[]; | ||
children?: DirectoryTree<C>[]; | ||
extension?: string; | ||
isSymbolicLink?: boolean; | ||
custom: { [key: string]: any }; | ||
custom: C; | ||
} | ||
export interface DirectoryTreeOptions { | ||
normalizePath ? : boolean; | ||
exclude ? : RegExp | RegExp[]; | ||
attributes ? : (keyof Stats | "type" | "extension")[]; | ||
extensions ? : RegExp; | ||
followSymlinks ? : boolean; | ||
depth ? : number; | ||
normalizePath?: boolean; | ||
exclude?: RegExp | RegExp[]; | ||
attributes?: (keyof Stats | "type" | "extension")[]; | ||
extensions?: RegExp; | ||
followSymlinks?: boolean; | ||
depth?: number; | ||
} | ||
export type DirectoryTreeCallback = (item: DirectoryTree, path: string, stats: Stats) => void; | ||
export type DirectoryTreeCallback<TCustom extends IObj = IObj> = ( | ||
item: DirectoryTree<TCustom>, | ||
path: string, | ||
stats: Stats | ||
) => void; | ||
} | ||
export = directoryTree; |
{ | ||
"name": "directory-tree", | ||
"version": "3.2.2", | ||
"version": "3.3.0", | ||
"description": "Convert a directory tree to a JS object.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -181,3 +181,3 @@ [](https://api.travis-ci.com/mihneadb/node-directory-tree.svg?branch=master) | ||
) => { | ||
item.custom.id = createHash('sha1').update(path).digest('base64'); | ||
item.custom = {id: createHash('sha1').update(path).digest('base64')}; | ||
}; | ||
@@ -184,0 +184,0 @@ |
17814
1.37%275
4.17%