From c88026cf86bbcfd01caea110ac89a5a081facd86 Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Tue, 21 May 2013 08:50:29 +0200 Subject: [PATCH] Executor also works without callbakc --- lib/executor.js | 48 ++++-------------------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) diff --git a/lib/executor.js b/lib/executor.js index f4a376e..10d328a 100644 --- a/lib/executor.js +++ b/lib/executor.js @@ -11,12 +11,7 @@ executor = async.queue(function (task, cb) { , lastArg = task.arguments[task.arguments.length - 1] ; - //console.log("=================="); - //console.log(task); - //console.log('---'); - //console.log(lastArg); - //console.log("=================="); - + // Always tell the queue task is complete. Execute callback if any was given. if (typeof lastArg === 'function') { callback = function () { lastArg(arguments); @@ -33,7 +28,7 @@ executor = async.queue(function (task, cb) { } task.fn.apply(task.this, task.arguments); -}, 2); +}, 1); function test1 (msg, cb) { @@ -61,7 +56,7 @@ function test2 (msg, cb) { function bloup () { console.log("FINISHED"); } -executor.push({ this: null, fn: test1, arguments: [ 'world', bloup ] }); +executor.push({ this: null, fn: test1, arguments: [ 'world' ] }); executor.push({ this: null, fn: test2, arguments: [ 'world', bloup ] }); @@ -123,42 +118,7 @@ q.unshift({name: 'bar'}, function (err) { }); */ -/* -function Executor () { -} - - -Executor.prototype.enqueueAction = function (fn, thisArg) { - var callback - , self = this - , lastArg = arguments[arguments.length - 1]; - - console.log(arguments); - console.log(arguments.length); - - // When finishing action, we need to launch the next one. We may also need to execute the callback for that action - if (lastArg === 'function') { - callback = function () { - lastArg(arguments); - self.launchNextAction(); - }; - } else { - callback = function () { - self.launchNextAction(); - }; - } -}; - -Executor.prototype.launchNextAction = function () { - console.log("LAUNCHED NEXT ACTION"); -}; - - - -var e = new Executor(); -e.enqueueAction(console.log, null, "a", 42); -*/ // Interface -//module.exports = Executor; +module.exports = executor;