From e829888c19f1d9b66bfbdadea824b5f63957d724 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 8 Dec 2022 01:02:57 +0300 Subject: [PATCH] cleanup and some plish... Signed-off-by: Alex A. Naanou --- Promise.js | 21 +++++++-------------- generator.js | 6 ++++-- package.json | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Promise.js b/Promise.js index bce5f78..a764f88 100644 --- a/Promise.js +++ b/Promise.js @@ -133,25 +133,18 @@ object.Constructor('IterablePromise', Promise, { if(!onerror){ list = [...list] // handle errors in input generator... + // NOTE: this does not offer the most control because semantically + // we bust behave in the same manner as .iter(..) } else { var res = [] try{ for(var e of list){ res.push(e) } - list = res }catch(err){ var r = onerror(err) - if(r === this.constructor.STOP - || r instanceof this.constructor.STOP){ - r instanceof this.constructor.STOP - && res.push(r.value) - list = res - } else { - list = r instanceof Array ? - r - : r ? - [r] - : [] } } } } + r !== undefined + && res.push(r) } + list = res } } // handle iterable promise... if(list instanceof IterablePromise){ return this.__handle(list.__packed, handler, onerror) } @@ -162,8 +155,8 @@ object.Constructor('IterablePromise', Promise, { return list .iter(handler, onerror) .then(function(list){ - return that.__pack(list) }) - } else if(list instanceof Promise){ + return that.__pack(list) }) } + if(list instanceof Promise){ return list .then(function(list){ return that.__pack(list, handler, onerror) }) } diff --git a/generator.js b/generator.js index 89ff35f..5b3fce1 100644 --- a/generator.js +++ b/generator.js @@ -583,8 +583,10 @@ object.Mixin('AsyncGeneratorProtoMixin', 'soft', { if(onerror){ if(!(err === STOP || err instanceof STOP)){ var res = onerror(err) - if(res){ - yield res } + if(res !== undefined){ + yield handler ? + handler(res) + : res } return } } throw err } }), diff --git a/package.json b/package.json index e422adc..6c7023a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-types", - "version": "6.24.8", + "version": "6.24.9", "description": "Generic JavaScript types and type extensions...", "main": "main.js", "scripts": {