Logos DX
    Preparing search index...
    • Returns an async iterator that watches for changes on filename, where filenameis either a file or a directory.

      import { watch } from 'node:fs/promises';

      const ac = new AbortController();
      const { signal } = ac;
      setTimeout(() => ac.abort(), 10000);

      (async () => {
      try {
      const watcher = watch(__filename, { signal });
      for await (const event of watcher)
      console.log(event);
      } catch (err) {
      if (err.name === 'AbortError')
      return;
      throw err;
      }
      })();

      On most platforms, 'rename' is emitted whenever a filename appears or disappears in the directory.

      All the caveats for fs.watch() also apply to fsPromises.watch().

      Parameters

      Returns AsyncIterator<FileChangeInfo<string>>

      of objects with the properties:

      v15.9.0, v14.18.0

    • Returns an async iterator that watches for changes on filename, where filenameis either a file or a directory.

      import { watch } from 'node:fs/promises';

      const ac = new AbortController();
      const { signal } = ac;
      setTimeout(() => ac.abort(), 10000);

      (async () => {
      try {
      const watcher = watch(__filename, { signal });
      for await (const event of watcher)
      console.log(event);
      } catch (err) {
      if (err.name === 'AbortError')
      return;
      throw err;
      }
      })();

      On most platforms, 'rename' is emitted whenever a filename appears or disappears in the directory.

      All the caveats for fs.watch() also apply to fsPromises.watch().

      Parameters

      Returns AsyncIterator<FileChangeInfo<NonSharedBuffer>>

      of objects with the properties:

      v15.9.0, v14.18.0

    • Returns an async iterator that watches for changes on filename, where filenameis either a file or a directory.

      import { watch } from 'node:fs/promises';

      const ac = new AbortController();
      const { signal } = ac;
      setTimeout(() => ac.abort(), 10000);

      (async () => {
      try {
      const watcher = watch(__filename, { signal });
      for await (const event of watcher)
      console.log(event);
      } catch (err) {
      if (err.name === 'AbortError')
      return;
      throw err;
      }
      })();

      On most platforms, 'rename' is emitted whenever a filename appears or disappears in the directory.

      All the caveats for fs.watch() also apply to fsPromises.watch().

      Parameters

      • filename: PathLike
      • options: BufferEncoding | "buffer" | WatchOptions

      Returns AsyncIterator<FileChangeInfo<string | NonSharedBuffer>>

      of objects with the properties:

      v15.9.0, v14.18.0