Skip to content

throttleWithLock

throttleWithLock(fn, wait?, options?): Function

使用 throttle 函数实现带有锁定功能的节流函数。

参数

NameTypeDefault valueDescription
fnFunctionundefined要执行的函数。
wait?number3000每次触发函数后的等待时间,在该时间间隔内不会再次执行函数。
options?Objectundefined配置选项。
options.leadingundefined | booleanundefined是否在触发开始时立即执行一次函数。
options.trailingundefined | booleanundefined是否在触发结束后再执行一次函数。

返回值

Function

  • 经过节流处理后的函数。

源码

throttle-with-lock.js