mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Apply rest arguments transform.
This commit is contained in:
@@ -18,9 +18,9 @@ function createBind(func, bitmask, thisArg) {
|
||||
var isBind = bitmask & WRAP_BIND_FLAG,
|
||||
Ctor = createCtor(func);
|
||||
|
||||
function wrapper() {
|
||||
function wrapper(...args) {
|
||||
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
|
||||
return fn.apply(isBind ? thisArg : this, arguments);
|
||||
return fn.apply(isBind ? thisArg : this, args);
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -18,19 +18,19 @@ function shortOut(func) {
|
||||
var count = 0,
|
||||
lastCalled = 0;
|
||||
|
||||
return function() {
|
||||
return function(...args) {
|
||||
var stamp = nativeNow(),
|
||||
remaining = HOT_SPAN - (stamp - lastCalled);
|
||||
|
||||
lastCalled = stamp;
|
||||
if (remaining > 0) {
|
||||
if (++count >= HOT_COUNT) {
|
||||
return arguments[0];
|
||||
return args[0];
|
||||
}
|
||||
} else {
|
||||
count = 0;
|
||||
}
|
||||
return func(...arguments);
|
||||
return func(...args);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
4
after.js
4
after.js
@@ -32,9 +32,9 @@ function after(n, func) {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
n = toInteger(n);
|
||||
return function() {
|
||||
return function(...args) {
|
||||
if (--n < 1) {
|
||||
return func.apply(this, arguments);
|
||||
return func.apply(this, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ function before(n, func) {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
n = toInteger(n);
|
||||
return function() {
|
||||
return function(...args) {
|
||||
if (--n > 0) {
|
||||
result = func.apply(this, arguments);
|
||||
result = func.apply(this, args);
|
||||
}
|
||||
if (n <= 1) {
|
||||
func = undefined;
|
||||
|
||||
@@ -33,11 +33,11 @@ import isArray from './isArray.js';
|
||||
* console.log(_.castArray(array) === array);
|
||||
* // => true
|
||||
*/
|
||||
function castArray() {
|
||||
if (!arguments.length) {
|
||||
function castArray(...args) {
|
||||
if (!args.length) {
|
||||
return [];
|
||||
}
|
||||
var value = arguments[0];
|
||||
var value = args[0];
|
||||
return isArray(value) ? value : [value];
|
||||
}
|
||||
|
||||
|
||||
@@ -157,11 +157,11 @@ function debounce(func, wait, options) {
|
||||
return timerId === undefined ? result : trailingEdge(now());
|
||||
}
|
||||
|
||||
function debounced() {
|
||||
function debounced(...args) {
|
||||
var time = now(),
|
||||
isInvoking = shouldInvoke(time);
|
||||
|
||||
lastArgs = arguments;
|
||||
lastArgs = args;
|
||||
lastThis = this;
|
||||
lastCallTime = time;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ var propertyIsEnumerable = objectProto.propertyIsEnumerable;
|
||||
* _.isArguments([1, 2, 3]);
|
||||
* // => false
|
||||
*/
|
||||
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : value => isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
||||
var isArguments = baseIsArguments(function(...args) { return args; }()) ? baseIsArguments : value => isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
||||
!propertyIsEnumerable.call(value, 'callee');
|
||||
|
||||
export default isArguments;
|
||||
|
||||
Reference in New Issue
Block a user