@push.rocks/smartchok
Version:
A cross-runtime file watcher with glob pattern support for Node.js, Deno, and Bun.
49 lines (48 loc) • 1.28 kB
TypeScript
import * as smartrx from '@push.rocks/smartrx';
import type { IWatcher, IWatcherOptions, IWatchEvent } from './interfaces.js';
/**
* Deno file watcher using native Deno.watchFs API
*/
export declare class DenoWatcher implements IWatcher {
private options;
private watcher;
private watchedFiles;
private _isWatching;
private abortController;
private recentEvents;
private throttleMs;
private pendingWrites;
readonly events$: smartrx.rxjs.Subject<IWatchEvent>;
constructor(options: IWatcherOptions);
get isWatching(): boolean;
start(): Promise<void>;
stop(): Promise<void>;
/**
* Process events from the Deno watcher
*/
private processEvents;
/**
* Handle a Deno file system event
*/
private handleDenoEvent;
/**
* Wait for file write to complete (polling-based)
*/
private waitForWriteFinish;
/**
* 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
*/
private isKnownDirectory;
/**
* Throttle duplicate events
*/
private shouldEmit;
}