Unverified Commit 98037294 authored by James M Snell's avatar James M Snell
Browse files

fs: add fsPromises.watch()



An alternative to `fs.watch()` that returns an `AsyncIterator`

```js
const { watch } = require('fs/promises');

(async () => {

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

  const watcher = watch('file.txt', { signal });

  for await (const { eventType, filename } of watcher) {
    console.log(eventType, filename);
  }

})()
```

Signed-off-by: default avatarJames M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/37179


Reviewed-By: default avatarBenjamin Gruenbaum <benjamingr@gmail.com>
parent ac24e505
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment