Debounces a function call, delaying its execution until a certain amount of time has passed without any new calls.
const a = debounce(1000, (x: number) => x * 2);a(1).then(console.log); // 2a(2).then(console.log); // still 2, until 1000ms have passed Copy
const a = debounce(1000, (x: number) => x * 2);a(1).then(console.log); // 2a(2).then(console.log); // still 2, until 1000ms have passed
The type of the function to be debounced.
The time in milliseconds to wait before executing the function.
The function to be debounced.
A function that returns a promise with the result of the debounced function.
Rest
Debounces a function call, delaying its execution until a certain amount of time has passed without any new calls.
Example