mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Bump to v4.14.0.
This commit is contained in:
30
rest.js
30
rest.js
@@ -1,4 +1,4 @@
|
||||
define(['./_apply', './toInteger'], function(apply, toInteger) {
|
||||
define(['./_baseRest', './toInteger'], function(baseRest, toInteger) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -6,9 +6,6 @@ define(['./_apply', './toInteger'], function(apply, toInteger) {
|
||||
/** 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 arguments from `start` and beyond provided as
|
||||
@@ -38,29 +35,8 @@ define(['./_apply', './toInteger'], function(apply, toInteger) {
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
|
||||
return function() {
|
||||
var args = arguments,
|
||||
index = -1,
|
||||
length = nativeMax(args.length - start, 0),
|
||||
array = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
array[index] = args[start + index];
|
||||
}
|
||||
switch (start) {
|
||||
case 0: return func.call(this, array);
|
||||
case 1: return func.call(this, args[0], array);
|
||||
case 2: return func.call(this, args[0], args[1], array);
|
||||
}
|
||||
var otherArgs = Array(start + 1);
|
||||
index = -1;
|
||||
while (++index < start) {
|
||||
otherArgs[index] = args[index];
|
||||
}
|
||||
otherArgs[start] = array;
|
||||
return apply(func, this, otherArgs);
|
||||
};
|
||||
start = start === undefined ? start : toInteger(start);
|
||||
return baseRest(func, start);
|
||||
}
|
||||
|
||||
return rest;
|
||||
|
||||
Reference in New Issue
Block a user