mirror of
https://github.com/flynx/types.js.git
synced 2025-12-20 02:11:39 +00:00
cleanup and some plish...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2ec383c0ee
commit
e829888c19
21
Promise.js
21
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 <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) }) }
|
||||
|
||||
@ -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 } }),
|
||||
|
||||
|
||||
@ -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": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user