ig-types 6.23.0 → 6.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Promise.js +20 -10
- package/README.md +7 -3
- package/package.json +1 -1
package/Promise.js
CHANGED
|
@@ -799,24 +799,27 @@ object.Constructor('ProxyPromise', Promise, {
|
|
|
799
799
|
// XXX DOCS...
|
|
800
800
|
// XXX like promise but if a value can be generated sync then this will
|
|
801
801
|
// run in sync otherwise it will fall back to being a promise...
|
|
802
|
-
// XXX
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
object.Constructor('MaybePromise', Promise, {
|
|
807
|
-
//error: undefined,
|
|
802
|
+
// XXX should we throw errors in sync mode??? ...option???
|
|
803
|
+
var SyncPromise =
|
|
804
|
+
module.SyncPromise =
|
|
805
|
+
object.Constructor('SyncPromise', Promise, {
|
|
808
806
|
//value: undefined,
|
|
807
|
+
//error: undefined,
|
|
809
808
|
|
|
809
|
+
// NOTE: if this is called it means that .__new__(..) returned in sync
|
|
810
|
+
// mode and thus set .value and possibly .error, soe there is no
|
|
811
|
+
// need to check for .value...
|
|
810
812
|
then: function(resolve, reject){
|
|
811
813
|
if(this.hasOwnProperty('error')){
|
|
812
814
|
return this.constructor.reject(
|
|
813
815
|
reject ?
|
|
814
816
|
reject(this.error)
|
|
815
817
|
: this.error) }
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
resolve(this.value)) } },
|
|
818
|
+
return this.constructor.resolve(
|
|
819
|
+
resolve(this.value)) },
|
|
819
820
|
|
|
821
|
+
// NOTE: if func calls resolve(..) with a promise then this will return
|
|
822
|
+
// that promise...
|
|
820
823
|
__new__: function(context, func){
|
|
821
824
|
var result
|
|
822
825
|
var resolve = function(res){
|
|
@@ -854,7 +857,7 @@ object.Mixin('PromiseMixin', 'soft', {
|
|
|
854
857
|
interactive: InteractivePromise,
|
|
855
858
|
cooperative: CooperativePromise,
|
|
856
859
|
// XXX EXPEREMENTAL...
|
|
857
|
-
|
|
860
|
+
sync: SyncPromise,
|
|
858
861
|
|
|
859
862
|
// XXX need error support...
|
|
860
863
|
awaitOrRun: function(data, func){
|
|
@@ -901,6 +904,13 @@ object.Mixin('PromiseProtoMixin', 'soft', {
|
|
|
901
904
|
as: ProxyPromise,
|
|
902
905
|
iter: function(handler=undefined){
|
|
903
906
|
return IterablePromise(this, handler) },
|
|
907
|
+
// XXX revise...
|
|
908
|
+
sync: function(){
|
|
909
|
+
if(this instanceof SyncPromise){
|
|
910
|
+
if('error' in this){
|
|
911
|
+
throw this.error }
|
|
912
|
+
return this.value }
|
|
913
|
+
return this },
|
|
904
914
|
})
|
|
905
915
|
|
|
906
916
|
PromiseProtoMixin(Promise.prototype)
|
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ Library of JavaScript type extensions, types and utilities.
|
|
|
94
94
|
- [Promise proxies](#promise-proxies)
|
|
95
95
|
- [`<promise>.as(..)`](#promiseas)
|
|
96
96
|
- [`<promise-proxy>.<method>(..)`](#promise-proxymethod)
|
|
97
|
-
- [Sync/
|
|
97
|
+
- [Sync/async promise](#syncasync-promise)
|
|
98
98
|
- [`Promise.maybe(..)` / `promise.MaybePromice(..)`](#promisemaybe--promisemaybepromice)
|
|
99
99
|
- [`<maybe-promise>.value` / `<maybe-promise>.error`](#maybe-promisevalue--maybe-promiseerror)
|
|
100
100
|
- [Promise utilities](#promise-utilities)
|
|
@@ -2007,11 +2007,15 @@ the main `<promise>` is resolved.
|
|
|
2007
2007
|
### Sync/async promise
|
|
2008
2008
|
|
|
2009
2009
|
|
|
2010
|
-
#### `Promise.
|
|
2010
|
+
#### `Promise.sync(..)` / `promise.SyncPromice(..)`
|
|
2011
2011
|
|
|
2012
2012
|
XXX
|
|
2013
2013
|
|
|
2014
|
-
#### `<
|
|
2014
|
+
#### `<sync-promise>.value` / `<sync-promise>.error`
|
|
2015
|
+
|
|
2016
|
+
XXX
|
|
2017
|
+
|
|
2018
|
+
#### `<promise>.sync()`
|
|
2015
2019
|
|
|
2016
2020
|
XXX
|
|
2017
2021
|
|