mirror of
https://github.com/flynx/types.js.git
synced 2025-10-28 10:00:08 +00:00
refactored runner's FinalizableQueue(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7cabc0605a
commit
e0cc0e6a14
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-types",
|
||||
"version": "6.24.18",
|
||||
"version": "6.24.19",
|
||||
"description": "Generic JavaScript types and type extensions...",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
28
runner.js
28
runner.js
@ -409,7 +409,7 @@ object.Constructor('Queue', Array, {
|
||||
// collect results...
|
||||
this.collect_results
|
||||
&& res !== module.SKIP
|
||||
&& (this.__results = this.__results || []).push(res)
|
||||
&& (this.__results = this.__results ?? []).push(res)
|
||||
|
||||
// handle task results...
|
||||
//
|
||||
@ -573,13 +573,15 @@ object.Constructor('FinalizableQueue', Queue, {
|
||||
|
||||
done: events.Event('done', function(handle){
|
||||
// abort only once...
|
||||
if(this.state == 'aborted' || this.state == 'done'){
|
||||
if(this.state == 'aborted'
|
||||
|| this.state == 'done'){
|
||||
return handle(false) }
|
||||
this.__state = 'done'
|
||||
Object.freeze(this) }),
|
||||
abort: events.Event('abort', function(handle){
|
||||
// abort only once...
|
||||
if(this.state == 'aborted' || this.state == 'done'){
|
||||
if(this.state == 'aborted'
|
||||
|| this.state == 'done'){
|
||||
return handle(false) }
|
||||
this.__state = 'aborted'
|
||||
Object.freeze(this) }),
|
||||
@ -587,18 +589,22 @@ object.Constructor('FinalizableQueue', Queue, {
|
||||
// NOTE: each handler will get called once when the next time the
|
||||
// queue is emptied...
|
||||
promise: function(){
|
||||
var that = this
|
||||
return new Promise(function(resolve, reject){
|
||||
that
|
||||
.one('done', function(){
|
||||
resolve(...(that.collect_results ?
|
||||
[that.__results || []]
|
||||
: [])) })
|
||||
.one('abort', reject) }) },
|
||||
return this.__promise },
|
||||
then: function(onresolve, onreject){
|
||||
return this.promise().then(...arguments) },
|
||||
catch: function(onreject){
|
||||
return this.promise().catch(...arguments) },
|
||||
|
||||
__init__: function(options){
|
||||
var that = this
|
||||
this.__promise = new Promise(function(resolve, reject){
|
||||
that
|
||||
.one('done', function(){
|
||||
resolve(...(that.collect_results ?
|
||||
[that.__results ?? []]
|
||||
: [])) })
|
||||
.one('abort', reject) })
|
||||
return object.parentCall(FinalizableQueue.prototype.__init__, this, ...arguments) },
|
||||
})
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user