Date

“Function” Methods

_.before(n, func)

source npm package

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.

引入版本

3.0.0

参数
n (number) : The number of calls at which func is no longer invoked.
func (Function) : The function to restrict.

返回值
(Function) : Returns the new restricted function.

示例
jQuery(element).on('click', _.before(5, addContactToList));
// => Allows adding up to 4 contacts to the list.