mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Make _.times use _.createCallback and rebuild docs and dist/builds.
Former-commit-id: 62393b4833b64cea226abdbb6f1488369de46677
This commit is contained in:
57
dist/lodash.underscore.js
vendored
57
dist/lodash.underscore.js
vendored
@@ -3404,6 +3404,23 @@
|
||||
* @param {Mixed} [thisArg] The `this` binding of the created callback.
|
||||
* @param {Number} [argCount=3] The number of arguments the callback accepts.
|
||||
* @returns {Function} Returns a callback function.
|
||||
* @example
|
||||
*
|
||||
* var stooges = [
|
||||
* { 'name': 'moe', 'age': 40 },
|
||||
* { 'name': 'larry', 'age': 50 }
|
||||
* ];
|
||||
*
|
||||
* // wrap to create custom callback shorthands
|
||||
* _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
|
||||
* var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
|
||||
* return !match ? func(callback, thisArg) : function(object) {
|
||||
* return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
|
||||
* };
|
||||
* });
|
||||
*
|
||||
* _.filter(stooges, 'age__gt45');
|
||||
* // => [{ 'name': 'larry', 'age': 50 }]
|
||||
*/
|
||||
function createCallback(func, thisArg, argCount) {
|
||||
if (func == null) {
|
||||
@@ -3498,6 +3515,26 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Defers executing the `func` function until the current call stack has cleared.
|
||||
* Additional arguments will be passed to `func` when it is invoked.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Functions
|
||||
* @param {Function} func The function to defer.
|
||||
* @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with.
|
||||
* @returns {Number} Returns the timer id.
|
||||
* @example
|
||||
*
|
||||
* _.defer(function() { alert('deferred'); });
|
||||
* // returns from the function before `alert` is called
|
||||
*/
|
||||
function defer(func) {
|
||||
var args = slice(arguments, 1);
|
||||
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the `func` function after `wait` milliseconds. Additional arguments
|
||||
* will be passed to `func` when it is invoked.
|
||||
@@ -3520,26 +3557,6 @@
|
||||
return setTimeout(function() { func.apply(undefined, args); }, wait);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defers executing the `func` function until the current call stack has cleared.
|
||||
* Additional arguments will be passed to `func` when it is invoked.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Functions
|
||||
* @param {Function} func The function to defer.
|
||||
* @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with.
|
||||
* @returns {Number} Returns the timer id.
|
||||
* @example
|
||||
*
|
||||
* _.defer(function() { alert('deferred'); });
|
||||
* // returns from the function before `alert` is called
|
||||
*/
|
||||
function defer(func) {
|
||||
var args = slice(arguments, 1);
|
||||
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that memoizes the result of `func`. If `resolver` is
|
||||
* passed, it will be used to determine the cache key for storing the result
|
||||
|
||||
Reference in New Issue
Block a user