debounce
type: function
since: v2.6.0
since: v2.6.0
The debounce function delays execution until no new calls are made for a specified duration.
Usage
import { debounce } from '@mustib/utils';
const fn = debounce(() => { console.log('debounced');}, 100);
fn();fn();fn(); // logs once after 100ms from the last callDefinition
function debounce<T extends Func = Func>(func: T, ms = 100): T { }Parameters
-
functype func = Function;- Function to debounce.
-
mstype ms = number;/* default value */const ms = 100;- Delay in milliseconds after the most recent call.
Returns
type T = Function;- Debounced function with the same call signature.