From f260b8a8544b67c2ad0432be44a02033275cb89b Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Mon, 8 Jul 2013 12:58:57 +0200 Subject: [PATCH] Fixed strange executor bug when not passing callback --- lib/executor.js | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) 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"