@push.rocks/smartchok
Version:
A cross-runtime file watcher with glob pattern support for Node.js, Deno, and Bun.
44 lines (43 loc) • 1.2 kB
TypeScript
import * as smartrx from '@push.rocks/smartrx';
import type { IWatcher, IWatcherOptions, IWatchEvent } from './interfaces.js';
/**
* Node.js/Bun file watcher using native fs.watch API
*/
export declare class NodeWatcher implements IWatcher {
private options;
private watchers;
private watchedFiles;
private _isWatching;
private writeStabilizer;
private recentEvents;
private throttleMs;
readonly events$: smartrx.rxjs.Subject<IWatchEvent>;
constructor(options: IWatcherOptions);
get isWatching(): boolean;
start(): Promise<void>;
stop(): Promise<void>;
/**
* Start watching a path (file or directory)
*/
private watchPath;
/**
* Handle raw fs.watch events and normalize them
*/
private handleFsEvent;
/**
* Scan directory and emit 'add' events for existing files
*/
private scanDirectory;
/**
* Safely stat a path, returning null if it doesn't exist
*/
private statSafe;
/**
* Check if a path was known to be a directory (for proper unlink event type)
*/
private isKnownDirectory;
/**
* Throttle duplicate events
*/
private shouldEmit;
}