Skip to content

Commit

Permalink
fix: stop mutating the arguments when calling multi (#480)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
reconbot authored and luin committed Jun 9, 2017
1 parent d287fdc commit a380030
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a380030

Please sign in to comment.