diff options
Diffstat (limited to 'lib/async.js')
-rw-r--r-- | lib/async.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/async.js b/lib/async.js index 263f27f..5da3622 100644 --- a/lib/async.js +++ b/lib/async.js @@ -139,13 +139,13 @@ // Similar to ES6's rest param (http://ariya.ofilabs.com/2013/03/es6-and-rest-parameter.html) // This accumulates the arguments passed into an array, after a given index. + // From underscore.js (https://github.com/jashkenas/underscore/pull/2140). function _restParam(func, startIndex) { startIndex = startIndex == null ? func.length - 1 : +startIndex; return function() { var length = Math.max(arguments.length - startIndex, 0); var rest = Array(length); - var index; - for (index = 0; index < length; index++) { + for (var index = 0; index < length; index++) { rest[index] = arguments[index + startIndex]; } switch (startIndex) { @@ -153,12 +153,13 @@ case 1: return func.call(this, arguments[0], rest); case 2: return func.call(this, arguments[0], arguments[1], rest); } - var args = Array(startIndex + 1); - for (index = 0; index < startIndex; index++) { - args[index] = arguments[index]; - } - args[startIndex] = rest; - return func.apply(this, args); + // Currently unused but handle cases outside of the switch statement: + // var args = Array(startIndex + 1); + // for (index = 0; index < startIndex; index++) { + // args[index] = arguments[index]; + // } + // args[startIndex] = rest; + // return func.apply(this, args); }; } |