From 7ff70850623e89ca41021afd9d8cade48b1f3bb0 Mon Sep 17 00:00:00 2001 From: Hexagon Date: Mon, 29 Apr 2024 19:24:32 +0000 Subject: [PATCH] FsWatcher example --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 635754e..cdb9e53 100644 --- a/README.md +++ b/README.md @@ -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(); +```