diff --git a/lib/executor.js b/lib/executor.js index 2f0307d..abb25c8 100644 --- a/lib/executor.js +++ b/lib/executor.js @@ -9,8 +9,11 @@ function Executor () { this.queue = async.queue(function (task, cb) { var callback , lastArg = task.arguments[task.arguments.length - 1] + , i, newArguments = [] ; + for (i = 0; i < task.arguments.length; i += 1) { newArguments.push(task.arguments[i]); } + // Always tell the queue task is complete. Execute callback if any was given. if (typeof lastArg === 'function') { callback = function () { @@ -18,17 +21,14 @@ function Executor () { cb(); }; - task.arguments[task.arguments.length - 1] = callback; + newArguments[newArguments.length - 1] = callback; } else { - callback = function () { - cb(); - }; - - // task.arguments is an array-like object so push is not available - task.arguments[task.arguments.length] = callback; + callback = function () { cb(); }; + newArguments.push(callback); } - task.fn.apply(task.this, task.arguments); + + task.fn.apply(task.this, newArguments); }, 1); } diff --git a/package.json b/package.json index b71552a..acd1941 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nedb", - "version": "0.7.12", + "version": "0.7.13", "author": { "name": "tldr.io", "email": "hello@tldr.io"