diff --git a/lib/util.js b/lib/util.js index 8682fc2ad..f5ad1889f 100644 --- a/lib/util.js +++ b/lib/util.js @@ -101,11 +101,8 @@ exports.clone = function(obj) { exports.deduplicateRequests = function(fn) { var callbacksByArgs = {}; return function() { - var callback = arguments[arguments.length - 1]; - var args = []; - for (var i = 0; i < arguments.length - 1; i++) { - args.push(arguments[i]); - } + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); var argString = JSON.stringify(args); var callbacks = exports.digOrCreate(callbacksByArgs, argString, function() {