UNPKG

fs-visitor

Version:

A Node.js library for recursively listing files and directories with customizable filtering and sorting options.

40 lines (37 loc) 1.22 kB
import { WriteFileOptions } from 'fs'; type ReadFileOptions = null | BufferEncoding | { encoding?: null | undefined; flag?: string | undefined; } | { encoding: BufferEncoding; flag?: string | undefined; }; type ReadFileSync = (options?: ReadFileOptions) => string | Buffer; type WriteFileSync = (data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions) => void; type AppendFileSync = (data: string | Uint8Array, options?: WriteFileOptions) => void; type EntryBase = { type: "directory" | "file" | string; name: string; level: number; absolute: string; relative: string; children: EntryBase[]; }; type EntryFS = EntryBase & { readFileSync: ReadFileSync; writeFileSync: WriteFileSync; appendFileSync: AppendFileSync; }; type SorterEntry = (a: EntryBase, b: EntryBase) => number; type FilterEntry = (entry: EntryBase) => boolean; type Options = { cwd?: string; deep?: number; filterEntry?: FilterEntry | FilterEntry[]; withDirectory?: boolean; sorter?: SorterEntry; relativePrefix?: string; useSlash?: boolean; asTree?: boolean; }; export { EntryFS as E, FilterEntry as F, Options as O, SorterEntry as S, EntryBase as a };