Skip to content

Commit

Permalink
FsWatcher example
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 29, 2024
1 parent 6887626 commit 7ff7085
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,16 @@ Types:
| Method | Deno | Node | Bun | Base implementation |
| --------- | ---- | ---- | --- | ------------------- |
| FSWatcher | X | X | X | node:fs/promises |

Examples:

```typescript
const watcher = FsWatcher();
for await (const event of watcher.watch(tempdir)) {
if (event.kind === "modify" && filePath == event.paths[0]) {
console.log(event);
break; // Stop watching after the first creation event
}
}
watcher.close();
```

0 comments on commit 7ff7085

Please sign in to comment.