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) {
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);
}

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

Loading…
Cancel
Save