UNPKG

@thi.ng/file-io

Version:

Assorted file I/O utils (w/ logging support) for NodeJS/Bun

36 lines 1.41 kB
import type { Predicate } from "@thi.ng/api"; import type { ILogger } from "@thi.ng/logger"; /** * Recursively reads given directory (up to given max. depth, default: infinite) * and yields sequence of file names matching given extension (or regexp or * predicate). * * @remarks * Files will be matched using their _full_ relative sub-path (starting with * given `dir`). If NO `match` is given, all files will be matched. Directories * will *not* be tested and are always traversed (up to given `maxDepth`). * * The optional `logger` is only used to log errors for files which couldn't be * accessed. * * @param dir * @param match * @param maxDepth * @param logger */ export declare const files: (dir: string, match?: string | RegExp | Predicate<string>, maxDepth?: number, logger?: ILogger) => IterableIterator<string>; /** * Similar to {@link files}, however yields iterator of only matching * sub-directories in given `dir`. Normal files are being ignored. * * @remarks * Like the matcher in {@link files}, the regex or predicate will be applied to * the _full_ sub-path (starting with `dir`) in order to determine a match. * * @param dir * @param match * @param maxDepth * @param logger */ export declare const dirs: (dir: string, match?: string | RegExp | Predicate<string>, maxDepth?: number, logger?: ILogger) => IterableIterator<string>; //# sourceMappingURL=files.d.ts.map