MCPcopy Index your code
hub / github.com/stackblitz/bolt.new / debounce

Function debounce

app/utils/debounce.ts:1–17  ·  view source on GitHub ↗
(fn: (...args: Args) => void, delay = 100)

Source from the content-addressed store, hash-verified

1export function debounce<Args extends any[]>(fn: (...args: Args) => void, delay = 100) {
2 if (delay === 0) {
3 return fn;
4 }
5
6 let timer: number | undefined;
7
8 return function <U>(this: U, ...args: Args) {
9 const context = this;
10
11 clearTimeout(timer);
12
13 timer = window.setTimeout(() => {
14 fn.apply(context, args);
15 }, delay);
16 };
17}

Callers 2

newEditorStateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected