UNPKG

@neodx/vfs

Version:

Simple virtual file system - working dir context, lazy changes, different modes, integrations and moreover

74 lines (71 loc) 2.04 kB
import { d as VfsDirent, m as VfsPlugin, B as BaseVfs } from '../_internal/types-Bu8eLcj4.js'; interface ScanPluginApi { scan(path?: string, params?: ScanVfsParams): Promise<string[]>; scan(params?: ScanVfsParams): Promise<string[]>; scan( path: string, params: ScanVfsParams & { withFileTypes: true; } ): Promise<ScannedItem[]>; scan( params: ScanVfsParams & { withFileTypes: true; } ): Promise<ScannedItem[]>; } interface ScanVfsParams { /** Path to scan. */ path?: string; /** * Should return false if the scanning for the current directory should be stopped. * @default False */ barrier?: ScanVfsDirentChecker; /** * Should return true if the item should be included in the result. * @default True */ filter?: ScanVfsDirentChecker; /** Custom abort signal. */ signal?: AbortSignal; /** Timeout in milliseconds. */ timeout?: number; /** Maximum depth to scan. */ maxDepth?: number; /** If true, the result will contain information about the path, depth, relativePath and dirent. */ withFileTypes?: boolean; /** Optional cache for optimizing multiple scans under relatively static conditions. */ cache?: ScanVfsCache; } interface ScannedItem { /** Current scanning depth. */ depth: number; /** Relative path to file or directory */ relativePath: string; dirent: VfsDirent; } type ScanVfsDirentChecker = (item: ScannedItem) => boolean; type ScanVfsCache = ReturnType<typeof createScanVfsCache>; declare function scan(): VfsPlugin<ScanPluginApi>; declare function scanVfs( vfs: BaseVfs, params: ScanVfsParams & { withFileTypes: true; } ): Promise<ScannedItem[]>; declare function scanVfs(vfs: BaseVfs, params?: ScanVfsParams): Promise<string[]>; declare const createScanVfsCache: () => { visited: Record<string, Promise<VfsDirent[]>>; clear(): void; }; export { type ScanPluginApi, type ScanVfsCache, type ScanVfsDirentChecker, type ScanVfsParams, type ScannedItem, createScanVfsCache, scan, scanVfs };