Limits the rate at which a function can be called.
const a = throttle(1000, (x: number) => x * 2);a(1).then(console.log); // 2a(2).then(console.log); // still 2, until 1000ms have passed Copy
const a = throttle(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
Limits the rate at which a function can be called.
Example