UNPKG

@jkcfg/std

Version:

jk standard library

45 lines (44 loc) 1.57 kB
/** * @module std/fs */ export declare class FileInfo { name: string; path: string; isdir: boolean; constructor(n: string, p: string, d: boolean); } export declare class Directory { name: string; path: string; files: FileInfo[]; constructor(n: string, p: string, files: FileInfo[]); } export interface InfoOptions { module?: string; } export declare function info(path: string, options?: InfoOptions): FileInfo; export interface DirOptions { module?: string; } export declare function dir(path: string, options?: DirOptions): Directory; export declare function join(base: string, name: string): string; export interface WalkOpts { pre?: (f: FileInfo) => boolean; post?: () => void; } /** walk is a generator function that yields the files and directories * under a given path, in a preorder traversal. "Preorder" means that * the traversal is depth-first, and a directory is yielded * immediately before the traversal examines its contents. * * @param path the starting point for the traversal, which should be a * directory. * * @param opts pre- and post-hooks for the walk. The pre-hook is * called for each directory after it is yielded; if it returns a * falsey value, the directory is not traversed. The post-hook is * called after a directory's contents have all been traversed. The * starting point does not get treated as part of the traversal, i.e., * it starts with the contents of the directory at `path`. */ export declare function walk(path: string, opts?: WalkOpts): IterableIterator<FileInfo>;