chokidar
- Version 4.0.3
- Published
- 149 kB
- 1 dependency
- MIT license
Install
npm i chokidar
yarn add chokidar
pnpm add chokidar
Overview
Minimal and efficient cross-platform file watching library
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Variables
variable _default
const _default: { watch: typeof watch; FSWatcher: typeof FSWatcher };
Functions
function watch
watch: (paths: string | string[], options?: ChokidarOptions) => FSWatcher;
Instantiates watcher with paths to be tracked.
Parameter paths
file / directory paths
Parameter options
opts, such as
atomic
,awaitWriteFinish
,ignored
, and othersReturns
an instance of FSWatcher for chaining.
Example 1
const watcher = watch('.').on('all', (event, path) => { console.log(event, path); }); watch('.', { atomic: true, awaitWriteFinish: true, ignored: (f, stats) => stats?.isFile() && !f.endsWith('.js') })
Classes
class FSWatcher
class FSWatcher extends EventEmitter<FSWatcherEventMap> {}
Watches files & directories for changes. Emitted events:
add
,addDir
,change
,unlink
,unlinkDir
,all
,error
new FSWatcher() .add(directories) .on('add', path => log('File', path, 'was added'))
constructor
constructor( _opts?: Partial< BasicOpts & { ignored: Matcher | Matcher[]; awaitWriteFinish: boolean | Partial<AWF>; } >);
property closed
closed: boolean;
property options
options: FSWInstanceOptions;
method add
add: ( paths_: Path | Path[], _origAdd?: string, _internal?: boolean) => FSWatcher;
Adds paths to be watched on an existing FSWatcher instance.
Parameter paths_
file or file list. Other arguments are unused
method close
close: () => Promise<void>;
Close watchers and remove all listeners from watched paths.
method emitWithAll
emitWithAll: (event: EventName, args: EmitArgs) => void;
method getWatched
getWatched: () => Record<string, string[]>;
Expose list of watched paths
Returns
for chaining
method unwatch
unwatch: (paths_: Path | Path[]) => FSWatcher;
Close watchers or start ignoring events from specified paths.
class WatchHelper
class WatchHelper {}
constructor
constructor(path: string, follow: boolean, fsw: FSWatcher);
property dirParts
dirParts: string[][];
property followSymlinks
followSymlinks: boolean;
property fsw
fsw: FSWatcher;
property fullWatchPath
fullWatchPath: string;
property path
path: string;
property statMethod
statMethod: 'stat' | 'lstat';
property watchPath
watchPath: string;
method entryPath
entryPath: (entry: EntryInfo) => Path;
method filterDir
filterDir: (entry: EntryInfo) => boolean;
method filterPath
filterPath: (entry: EntryInfo) => boolean;
Interfaces
interface FSWatcherKnownEventMap
interface FSWatcherKnownEventMap {}
property [EV.ALL]
[EV.ALL]: [event: EventName, ...EmitArgs];
property [EV.ERROR]
[EV.ERROR]: Parameters<WatchHandlers['errHandler']>;
property [EV.RAW]
[EV.RAW]: Parameters<WatchHandlers['rawEmitter']>;
property [EV.READY]
[EV.READY]: [];
interface MatcherObject
interface MatcherObject {}
Type Aliases
type ChokidarOptions
type ChokidarOptions = Partial< BasicOpts & { ignored: Matcher | Matcher[]; awaitWriteFinish: boolean | Partial<AWF>; }>;
type EmitArgs
type EmitArgs = [path: Path, stats?: Stats];
type EmitArgsWithName
type EmitArgsWithName = [event: EventName, ...EmitArgs];
type EmitErrorArgs
type EmitErrorArgs = [error: Error, stats?: Stats];
type FSWatcherEventMap
type FSWatcherEventMap = FSWatcherKnownEventMap & { [k in Exclude<EventName, keyof FSWatcherKnownEventMap>]: EmitArgs;};
type FSWInstanceOptions
type FSWInstanceOptions = BasicOpts & { ignored: Matcher[]; awaitWriteFinish: false | AWF;};
type Matcher
type Matcher = string | RegExp | MatchFunction | MatcherObject;
type MatchFunction
type MatchFunction = (val: string, stats?: Stats) => boolean;
type Throttler
type Throttler = { timeoutObject: NodeJS.Timeout; clear: () => void; count: number;};
type ThrottleType
type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';
Package Files (1)
Dependencies (1)
Dev Dependencies (9)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/chokidar
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/chokidar)
- HTML<a href="https://www.jsdocs.io/package/chokidar"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3837 ms. - Missing or incorrect documentation? Open an issue for this package.