ig-types 6.24.2 → 6.24.3
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 +15 -13
- package/package.json +1 -1
package/Promise.js
CHANGED
|
@@ -849,13 +849,16 @@ object.Constructor('SyncPromise', Promise, {
|
|
|
849
849
|
// mode and thus set .value and possibly .error, soe there is no
|
|
850
850
|
// need to check for .value...
|
|
851
851
|
then: function(resolve, reject){
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
852
|
+
return this.hasOwnProperty('error') ?
|
|
853
|
+
this.constructor.reject(
|
|
854
|
+
reject ?
|
|
855
|
+
reject(this.error)
|
|
856
|
+
: this.error)
|
|
857
|
+
: resolve ?
|
|
858
|
+
this.constructor.resolve(
|
|
859
|
+
resolve(this.value))
|
|
860
|
+
// XXX should we return a copy???
|
|
861
|
+
: this },
|
|
859
862
|
|
|
860
863
|
// NOTE: if func calls resolve(..) with a promise then this will return
|
|
861
864
|
// that promise...
|
|
@@ -895,10 +898,8 @@ object.Mixin('PromiseMixin', 'soft', {
|
|
|
895
898
|
iter: IterablePromise,
|
|
896
899
|
interactive: InteractivePromise,
|
|
897
900
|
cooperative: CooperativePromise,
|
|
898
|
-
// XXX EXPEREMENTAL...
|
|
899
901
|
sync: SyncPromise,
|
|
900
|
-
|
|
901
|
-
// XXX need error support...
|
|
902
|
+
// XXX should this be implemented via SyncPromise???
|
|
902
903
|
awaitOrRun: function(data, func){
|
|
903
904
|
data = [...arguments]
|
|
904
905
|
func = data.pop()
|
|
@@ -943,11 +944,12 @@ object.Mixin('PromiseProtoMixin', 'soft', {
|
|
|
943
944
|
as: ProxyPromise,
|
|
944
945
|
iter: function(handler=undefined){
|
|
945
946
|
return IterablePromise(this, handler) },
|
|
946
|
-
|
|
947
|
-
sync: function(){
|
|
947
|
+
sync: function(error='throw'){
|
|
948
948
|
if(this instanceof SyncPromise){
|
|
949
949
|
if('error' in this){
|
|
950
|
-
|
|
950
|
+
if(typeof(error) != 'function'){
|
|
951
|
+
throw this.error }
|
|
952
|
+
return error(this.error) }
|
|
951
953
|
return this.value }
|
|
952
954
|
return this },
|
|
953
955
|
})
|