cleanup and some plish...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-12-08 01:02:57 +03:00
parent 2ec383c0ee
commit e829888c19
3 changed files with 12 additions and 17 deletions

View File

@ -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 <generator>.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) }) }

View File

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

View File

@ -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": {