The 𝗳𝘀𝗣𝗿𝗼𝗺𝗶𝘀𝗲𝘀.𝘄𝗮𝘁𝗰𝗵 method returns an async iterator that watches for changes on 𝗳𝗶𝗹𝗲𝗻𝗮𝗺𝗲, where 𝗳𝗶𝗹𝗲𝗻𝗮𝗺𝗲 is either a file or a directory.
By default, it uses 𝘂𝘁𝗳𝟴 encoding and keeps the process running as long as the file/dir is being watched.
Optionally, you could pass an 𝗔𝗯𝗼𝗿𝘁𝗦𝗶𝗴𝗻𝗮𝗹 to signal when the watcher should stop.
Keep in mind that this API comes with a few caveats. For example, not being consistent across platforms; the recursive option is only supported on macOS and Windows.
So make sure to check all the caveats..
Did you learn something new today?
Like and share this post, and follow me for more!
Top comments (0)