Skip to content

Commit a380030

Browse files
reconbotluin
authored andcommitted
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.
1 parent d287fdc commit a380030

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/pipeline.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,12 @@ Pipeline.prototype.sendCommand = function (command) {
180180
};
181181

182182
Pipeline.prototype.addBatch = function (commands) {
183+
var command, commandName, args;
183184
for (var i = 0; i < commands.length; ++i) {
184-
var command = commands[i];
185-
var commandName = command.shift();
186-
this[commandName].apply(this, command);
185+
command = commands[i];
186+
commandName = command[0];
187+
args = command.slice(1);
188+
this[commandName].apply(this, args);
187189
}
188190

189191
return this;

0 commit comments

Comments
 (0)