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