From bf54267f0bcd2119bbbf6b8ece8b0afb49904cc2 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 6 Jan 2017 15:49:42 -0800 Subject: [PATCH] Apply rest arguments transform. --- _createBind.js | 4 ++-- _shortOut.js | 6 +++--- after.js | 4 ++-- before.js | 4 ++-- castArray.js | 6 +++--- debounce.js | 4 ++-- isArguments.js | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/_createBind.js b/_createBind.js index 3083ae498..ff5f7de8e 100644 --- a/_createBind.js +++ b/_createBind.js @@ -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; } diff --git a/_shortOut.js b/_shortOut.js index 7ee6f61e5..aca9906ca 100644 --- a/_shortOut.js +++ b/_shortOut.js @@ -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); }; } diff --git a/after.js b/after.js index f05a32d33..8cf7c20a7 100644 --- a/after.js +++ b/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); } }; } diff --git a/before.js b/before.js index 15a670b1f..152c10700 100644 --- a/before.js +++ b/before.js @@ -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; diff --git a/castArray.js b/castArray.js index 1ec560a28..7108bdb17 100644 --- a/castArray.js +++ b/castArray.js @@ -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]; } diff --git a/debounce.js b/debounce.js index 645754d54..ec8171936 100644 --- a/debounce.js +++ b/debounce.js @@ -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; diff --git a/isArguments.js b/isArguments.js index 6753346b3..3a906b3cb 100644 --- a/isArguments.js +++ b/isArguments.js @@ -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;