@freik/node-utils
Version:
My personal set of utilities for NodeJS
23 lines (22 loc) • 1.14 kB
TypeScript
export type PathHandlerAsync = (pathName: string) => Promise<void>;
export type PathHandlerSync = (pathName: string) => void;
export type PathHandlerEither = PathHandlerSync | PathHandlerAsync;
export type PathHandlerBoth = (pathName: string) => Promise<void> | void;
export type PathHandlerAll = PathHandlerBoth | PathHandlerEither;
export type FileIndex = {
getLocation: () => string;
forEachFile: (fn: PathHandlerAll) => Promise<void>;
forEachFileSync: (fn: PathHandlerSync) => void;
getLastScanTime: () => Date | null;
rescanFiles: (addFile?: PathHandlerAll, delFile?: PathHandlerAll) => Promise<void>;
};
export type Watcher = (obj: string) => boolean;
export declare function AndWatch(...watchers: (Watcher | undefined)[]): Watcher;
export declare function OrWatch(...watchers: (Watcher | undefined)[]): Watcher;
export declare function NotWatch(w: Watcher | undefined): Watcher;
export type FileIndexOptions = {
indexFolderLocation: string;
fileWatcher: Watcher;
watchHidden: boolean;
};
export declare function MakeFileIndex(location: string, options?: Partial<FileIndexOptions>): Promise<FileIndex>;