tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-12-04 17:01:15 +03:00
parent 27307dc4e5
commit 5d558b35b6
2 changed files with 16 additions and 14 deletions

View File

@ -849,13 +849,16 @@ object.Constructor('SyncPromise', Promise, {
// mode and thus set .value and possibly .error, soe there is no
// need to check for .value...
then: function(resolve, reject){
if(this.hasOwnProperty('error')){
return this.constructor.reject(
reject ?
reject(this.error)
: this.error) }
return this.constructor.resolve(
resolve(this.value)) },
return this.hasOwnProperty('error') ?
this.constructor.reject(
reject ?
reject(this.error)
: this.error) }
: resolve ?
this.constructor.resolve(
resolve(this.value))
// XXX should we return a copy???
: this },
// NOTE: if func calls resolve(..) with a promise then this will return
// that promise...
@ -895,10 +898,8 @@ object.Mixin('PromiseMixin', 'soft', {
iter: IterablePromise,
interactive: InteractivePromise,
cooperative: CooperativePromise,
// XXX EXPEREMENTAL...
sync: SyncPromise,
// XXX need error support...
// XXX should this be implemented via SyncPromise???
awaitOrRun: function(data, func){
data = [...arguments]
func = data.pop()
@ -943,11 +944,12 @@ object.Mixin('PromiseProtoMixin', 'soft', {
as: ProxyPromise,
iter: function(handler=undefined){
return IterablePromise(this, handler) },
// XXX revise...
sync: function(){
sync: function(error='throw'){
if(this instanceof SyncPromise){
if('error' in this){
throw this.error }
if(typeof(error) != 'function'){
throw this.error }
return error(this.error) }
return this.value }
return this },
})

View File

@ -1,6 +1,6 @@
{
"name": "ig-types",
"version": "6.24.2",
"version": "6.24.3",
"description": "Generic JavaScript types and type extensions...",
"main": "main.js",
"scripts": {