From a380030d6c8ccaadb1de0d25bf4063213776dfd0 Mon Sep 17 00:00:00 2001 From: Francis Gulotta Date: Thu, 8 Jun 2017 22:46:10 -0400 Subject: [PATCH] fix: stop mutating the arguments when calling multi (#480) This copies the arguments for a multi command instead of mutating the passed in arrays. This allows users to log the commands that gave an error if the multi command errors. --- lib/pipeline.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/pipeline.js b/lib/pipeline.js index eba25cfa..3af74c40 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -180,10 +180,12 @@ Pipeline.prototype.sendCommand = function (command) { }; Pipeline.prototype.addBatch = function (commands) { + var command, commandName, args; for (var i = 0; i < commands.length; ++i) { - var command = commands[i]; - var commandName = command.shift(); - this[commandName].apply(this, command); + command = commands[i]; + commandName = command[0]; + args = command.slice(1); + this[commandName].apply(this, args); } return this;