more tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-12-05 06:37:01 +03:00
parent ea242452bb
commit 62c00a9fd4
3 changed files with 28 additions and 6 deletions

View File

@ -948,9 +948,12 @@ object.Mixin('PromiseProtoMixin', 'soft', {
as: ProxyPromise,
iter: function(handler=undefined){
return IterablePromise(this, handler) },
// XXX should we try and return a sync value if normal promise is resolved???
// ...sould need to hook .then(..) to do this...
sync: function(error='throw'){
if(this instanceof SyncPromise){
if('error' in this){
if(error !== false
&& 'error' in this){
if(typeof(error) != 'function'){
throw this.error }
return error(this.error) }

View File

@ -2034,10 +2034,29 @@ Example:
-->
#### `<promise>.sync()`
#### `<promise>.sync(..)`
Synchronously return the resolved value if `<sync-promise>` resolved, and
if it _rejected_ then re-throw the `<error>`.
if it _rejected_ then re-throw the `<error>`. Normal promises will return self.
```bnf
<promise>.sync()
-> <value>
-> <promise>
```
To suppress errors pass `false` to `.sync(..)` and to handle them differently
pass an error handler function.
```bnf
<promise>.sync(false)
-> <value>
<promise>.sync(<onerror>)
-> <value>
<onerror>(<error>)
-> <value>
```
#### `<sync-promise>.value` / `<sync-promise>.error`
@ -2048,8 +2067,8 @@ rejection `.error`.
#### `Promise.sync.all(..)` / `Promise.sync.allSettled(..)` / `Promise.sync.any(..)` / `Promise.sync.race(..)`
Equivalents to `Promise`'s version but will run sync if the relevant
items in the input are either non-promises or `<sync-promise>`s.
Equivalents to `Promise`'s respective versions but will run sync if the
relevant items in the input are either non-promises or `<sync-promise>`s.

View File

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