The function to debounce.
The time in milliseconds to delay the function.
const log = debounce(
(event: Deno.FsEvent) =>
console.log("[%s] %s", event.kind, event.paths[0]),
200,
);
for await (const event of Deno.watchFs("./")) {
log(event);
}
Forked from third-party library
https://github.com/denoland/deno_std/blob/main/async/debounce.ts
The Deno authors
MIT
Creates a debounced function that delays the given
func
by a givenwait
time in milliseconds. If the method is called again before the timeout expires, the previous call will be aborted.