mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 13:14:44 +00:00
.
This commit is contained in:
parent
00c3b50fca
commit
ae5dcb46c8
7331 changed files with 1784502 additions and 0 deletions
40
node_modules/lodash/before.js
generated
vendored
Normal file
40
node_modules/lodash/before.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
var toInteger = require('./toInteger');
|
||||
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.0.0
|
||||
* @category Function
|
||||
* @param {number} n The number of calls at which `func` is no longer invoked.
|
||||
* @param {Function} func 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.
|
||||
*/
|
||||
function before(n, func) {
|
||||
var result;
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
n = toInteger(n);
|
||||
return function() {
|
||||
if (--n > 0) {
|
||||
result = func.apply(this, arguments);
|
||||
}
|
||||
if (n <= 1) {
|
||||
func = undefined;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = before;
|
Loading…
Add table
Add a link
Reference in a new issue