Fixed strange executor bug when not passing callback

pull/2/head
Louis Chatriot 12 years ago
parent ccc766ca2a
commit f260b8a854
  1. 16
      lib/executor.js
  2. 2
      package.json

@ -9,8 +9,11 @@ function Executor () {
this.queue = async.queue(function (task, cb) { this.queue = async.queue(function (task, cb) {
var callback var callback
, lastArg = task.arguments[task.arguments.length - 1] , 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. // Always tell the queue task is complete. Execute callback if any was given.
if (typeof lastArg === 'function') { if (typeof lastArg === 'function') {
callback = function () { callback = function () {
@ -18,17 +21,14 @@ function Executor () {
cb(); cb();
}; };
task.arguments[task.arguments.length - 1] = callback; newArguments[newArguments.length - 1] = callback;
} else { } else {
callback = function () { callback = function () { cb(); };
cb(); newArguments.push(callback);
};
// task.arguments is an array-like object so push is not available
task.arguments[task.arguments.length] = callback;
} }
task.fn.apply(task.this, task.arguments);
task.fn.apply(task.this, newArguments);
}, 1); }, 1);
} }

@ -1,6 +1,6 @@
{ {
"name": "nedb", "name": "nedb",
"version": "0.7.12", "version": "0.7.13",
"author": { "author": {
"name": "tldr.io", "name": "tldr.io",
"email": "hello@tldr.io" "email": "hello@tldr.io"

Loading…
Cancel
Save