chokidar
- Version 6.0.0
- Published
- 202 kB
- 1 dependency
- MIT license
Install
npm i chokidaryarn add chokidarpnpm add chokidarOverview
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,errornew FSWatcher() .add(directories) .on('add', path => log('File', path, 'was added'))
constructor
constructor( _opts?: Partial< BasicOptions & { ignored: Matcher | Matcher[]; awaitWriteFinish: boolean | Partial<AWF>; } >, scheduler?: Scheduler);property closed
readonly closed: boolean;property options
options: FSWInstanceOptions;method add
add: (paths_: Path | Path[]) => FSWatcher;Adds paths to be watched on an existing FSWatcher instance.
Parameter paths_
file or file list
method close
close: () => Promise<void>;Close watchers and remove all listeners from watched paths.
method getWatched
getWatched: () => Record<string, string[]>;Expose list of watched paths. The result has a null prototype, so a directory named
__proto__is an ordinary own key.
method unwatch
unwatch: (paths_: Path | Path[]) => FSWatcher;Close watchers or start ignoring events from specified paths.
Interfaces
interface FSWatcherEventMap
interface FSWatcherEventMap {}property [EV.ADD_DIR]
[EV.ADD_DIR]: EmitArgs;property [EV.ADD]
[EV.ADD]: EmitArgs;property [EV.ALL]
[EV.ALL]: [event: EventName, ...EmitArgs];property [EV.CHANGE]
[EV.CHANGE]: EmitArgs;property [EV.ERROR]
[EV.ERROR]: Parameters<WatchHandlers['errHandler']>;property [EV.RAW]
[EV.RAW]: Parameters<WatchHandlers['rawEmitter']>;property [EV.READY]
[EV.READY]: [];property [EV.UNLINK_DIR]
[EV.UNLINK_DIR]: EmitArgs;property [EV.UNLINK]
[EV.UNLINK]: EmitArgs;interface Scheduler
interface Scheduler {}method clearTimeout
clearTimeout: (timer: SchedulerTimer | undefined) => void;method now
now: () => number;method setTimeout
setTimeout: (callback: () => void, delay: number) => SchedulerTimer;interface SchedulerTimer
interface SchedulerTimer {}Type Aliases
type AWF
type AWF = { stabilityThreshold: number; pollInterval: number;};type BackendStrategy
type BackendStrategy = | 'polling' | 'native-per-directory' | 'native-recursive-preferred';type ChokidarOptions
type ChokidarOptions = Partial< BasicOptions & { 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 FSWInstanceOptions
type FSWInstanceOptions = BasicOptions & { ignored: readonly Matcher[]; awaitWriteFinish: false | AWF; backendStrategy: BackendStrategy; backendCapabilities: import('./backend.js').BackendCapabilities;};type Matcher
type Matcher = string | RegExp | MatchFunction | MatcherObject;type MatcherObject
type MatcherObject = { path: string; recursive?: boolean;};type MatchFunction
type MatchFunction = (val: string, stats?: Stats) => boolean;type Throttler
type Throttler = { timeoutObject: SchedulerTimer; clear: (invokeRelease?: boolean) => number; count: number;};type ThrottleType
type ThrottleType = 'readdir' | 'watch' | 'add' | 'remove' | 'change';type WatchBackend
type WatchBackend = 'auto' | 'native' | 'native-recursive' | 'polling';Package Files (2)
Dependencies (1)
Dev Dependencies (4)
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[](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 2761 ms. - Missing or incorrect documentation? Open an issue for this package.
