_.before(n, func)
Creates a function that invokes func
, with the this
binding and arguments of the created function, while it's called less than n
times. Subsequent calls to the created function return the result of the last func
invocation.
Since
3.0.0
Arguments
n
(number): The number of calls at whichfunc
is no longer invoked.func
(Function): The function to restrict.
Returns
(Function): Returns the new restricted function.
Example
jQuery(element).on('click', _.before(5, addContactToList));// => Allows adding up to 4 contacts to the list.
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .