Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
function debounce
import { debounce } from "https://deno.land/x/denogres@v4.0.1/vendor/deno.land/std@0.160.0/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.

import { debounce } from "https://deno.land/std@0.224.0/async/debounce.ts";

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);
}

Type Parameters

T extends Array<any>

Parameters

fn: (this: DebouncedFunction<T>, ...args: T) => void

The function to debounce.

wait: number

The time in milliseconds to delay the function.