Bump to v4.2.0.

This commit is contained in:
John-David Dalton
2016-02-01 23:13:04 -08:00
parent 7293d39642
commit 5ca813254d
62 changed files with 303 additions and 271 deletions

View File

@@ -1,8 +1,14 @@
define(['./_apply'], function(apply) {
define(['./_apply', './_arrayPush', './rest', './toInteger'], function(apply, arrayPush, rest, toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
/**
* Creates a function that invokes `func` with the `this` binding of the created
* function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).
@@ -13,6 +19,7 @@ define(['./_apply'], function(apply) {
* @memberOf _
* @category Function
* @param {Function} func The function to spread arguments over.
* @param {number} [start=0] The start position of the spread.
* @returns {Function} Returns the new function.
* @example
*
@@ -23,7 +30,6 @@ define(['./_apply'], function(apply) {
* say(['fred', 'hello']);
* // => 'fred says hello'
*
* // with a Promise
* var numbers = Promise.all([
* Promise.resolve(40),
* Promise.resolve(36)
@@ -34,13 +40,20 @@ define(['./_apply'], function(apply) {
* }));
* // => a Promise of 76
*/
function spread(func) {
function spread(func, start) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function(array) {
return apply(func, this, array);
};
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return rest(function(args) {
var array = args[start],
otherArgs = args.slice(0, start);
if (array) {
arrayPush(otherArgs, array);
}
return apply(func, this, otherArgs);
});
}
return spread;