From 8f2c47c4e6a67456d736a0f14070a82cb3c2702c Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 2 Dec 2020 06:28:11 +0300 Subject: [PATCH] minor simplification... Signed-off-by: Alex A. Naanou --- package.json | 2 +- runner.js | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 2466a2a..c218491 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-types", - "version": "5.0.30", + "version": "5.0.31", "description": "Generic JavaScript types and type extensions...", "main": "main.js", "scripts": { diff --git a/runner.js b/runner.js index 364ae0a..c8165b9 100644 --- a/runner.js +++ b/runner.js @@ -53,6 +53,8 @@ module.STOP = object.STOP // - not consistent -- a task can be added via .add(..) and // the Array interface and only .add(..) will trigger the // proper events... +// XXX document the Queue({handler: e => e*e}, 1,2,3,4) use-case... +// ...this is essentially a .map(..) variant... var Queue = module.Queue = object.Constructor('Queue', Array, { @@ -63,8 +65,6 @@ object.Constructor('Queue', Array, { }, events.EventMixin('flat', { // config... // - handler: null, - pool_size: 8, poling_delay: 200, @@ -144,7 +144,7 @@ object.Constructor('Queue', Array, { // Runner API... // // Run the given task type... - // .__run_task__(task[, next]) + // .handler(task[, next]) // -> STOP // -> STOP(value) // -> queue @@ -157,10 +157,8 @@ object.Constructor('Queue', Array, { // ...to add a new task/result type either handle the non-standard // result here or wrap it into a standard return value like a // promise... - __run_task__: function(task, next){ - return typeof(this.handler) == 'function' ? - this.handler(task) - : typeof(task) == 'function' ? + handler: function(task, next){ + return typeof(task) == 'function' ? task() : (task instanceof Queue && this.sub_queue == 'unwind') ? @@ -252,7 +250,7 @@ object.Constructor('Queue', Array, { if(this.catch_errors){ var err try { - var res = this.__run_task__(task, next) + var res = this.handler(task, next) } catch(err){ this.trigger('taskFailed', task, err) } @@ -267,7 +265,7 @@ object.Constructor('Queue', Array, { // ignore errors... } else { - var res = this.__run_task__(task, next) } + var res = this.handler(task, next) } // handle stop... var stop = res === module.STOP