Skip to main content
FSWatcher - fs - Node documentation
interface FSWatcher
extends EventEmitter

Usage in Deno

import { type FSWatcher } from "node:fs";

Methods

close(): void

Stop watching for changes on the given fs.FSWatcher. Once stopped, the fs.FSWatcher object is no longer usable.

ref(): this

When called, requests that the Node.js event loop not exit so long as the fs.FSWatcher is active. Calling watcher.ref() multiple times will have no effect.

By default, all fs.FSWatcher objects are "ref'ed", making it normally unnecessary to call watcher.ref() unless watcher.unref() had been called previously.

unref(): this

When called, the active fs.FSWatcher object will not require the Node.js event loop to remain active. If there is no other activity keeping the event loop running, the process may exit before the fs.FSWatcher object's callback is invoked. Calling watcher.unref() multiple times will have no effect.

addListener(
event: string,
listener: (...args: any[]) => void,
): this

events.EventEmitter

  1. change
  2. close
  3. error
addListener(
event: "change",
listener: (
eventType: string,
filename: string | Buffer,
) => void
,
): this
addListener(
event: "close",
listener: () => void,
): this
addListener(
event: "error",
listener: (error: Error) => void,
): this
on(
event: string,
listener: (...args: any[]) => void,
): this
on(
event: "change",
listener: (
eventType: string,
filename: string | Buffer,
) => void
,
): this
on(
event: "close",
listener: () => void,
): this
on(
event: "error",
listener: (error: Error) => void,
): this
once(
event: string,
listener: (...args: any[]) => void,
): this
once(
event: "change",
listener: (
eventType: string,
filename: string | Buffer,
) => void
,
): this
once(
event: "close",
listener: () => void,
): this
once(
event: "error",
listener: (error: Error) => void,
): this
prependListener(
event: string,
listener: (...args: any[]) => void,
): this
prependListener(
event: "change",
listener: (
eventType: string,
filename: string | Buffer,
) => void
,
): this
prependListener(
event: "close",
listener: () => void,
): this
prependListener(
event: "error",
listener: (error: Error) => void,
): this
prependOnceListener(
event: string,
listener: (...args: any[]) => void,
): this
prependOnceListener(
event: "change",
listener: (
eventType: string,
filename: string | Buffer,
) => void
,
): this
prependOnceListener(
event: "close",
listener: () => void,
): this
prependOnceListener(
event: "error",
listener: (error: Error) => void,
): this