import { debounce } from "https://deno.land/std@0.218.2/async/debounce.ts";
Creates a debounced function that delays the given func
by a given wait
time in milliseconds. If the method is called
again before the timeout expires, the previous call will be
aborted.
Examples
Example 1
Example 1
import { debounce } from "https://deno.land/std@0.218.2/async/debounce.ts";
await Array.fromAsync(
Deno.watchFs('./'),
debounce((event) => {
console.log('[%s] %s', event.kind, event.paths[0]);
}, 200),
);
// wait 200ms ...
// output: Function debounced after 200ms with baz
Parameters
fn: (this: DebouncedFunction<T>, ...args: T) => void
The function to debounce.