Home > @ailer/pocket > throttle
throttle() function
节流函数,限制某个函数在一定时间间隔内只能执行一次
Signature:
typescript
throttle: (fn: (...args: any) => void, wait?: number, { leading, trailing }?: {
leading?: boolean | undefined;
trailing?: boolean | undefined;
}, hint?: () => void) => (...args: any) => void
Parameters
Parameter | Type | Description |
---|---|---|
fn | (...args: any) => void | 需要节流的函数 |
wait | number | (Optional) 节流时间间隔,默认为 1000 毫秒 |
{ leading?: boolean | undefined; trailing?: boolean | undefined; } | (Optional) | |
hint | () => void | (Optional) 节流期间执行的函数,用于提示 |
(...args: any) => void
节流后的函数