Index: src/js/promise.js |
diff --git a/src/js/promise.js b/src/js/promise.js |
index 20ffc8c4892327ac68f5242c7900a1006303959e..2f8d5567ceb37aa37832bd8fe4c23e7b446b0486 100644 |
--- a/src/js/promise.js |
+++ b/src/js/promise.js |
@@ -386,8 +386,20 @@ function PromiseCreateRejected(r) { |
return %_Call(PromiseReject, GlobalPromise, r); |
} |
-function PromiseCreateResolved(x) { |
- return %_Call(PromiseResolve, GlobalPromise, x); |
+function PromiseCreateResolved(value) { |
+ var promise = PromiseInit(new GlobalPromise(promiseRawSymbol)); |
+ var resolveResult = ResolvePromise(promise, value); |
+ return promise; |
+} |
+ |
+function PromiseCastResolved(value) { |
caitp
2016/08/06 00:55:50
nit: an alternative name for this would be very ni
|
+ if (IsPromise(value)) { |
+ return value; |
+ } else { |
+ var promise = PromiseInit(new GlobalPromise(promiseRawSymbol)); |
+ var resolveResult = ResolvePromise(promise, value); |
+ return promise; |
+ } |
} |
function PerformPromiseThen(promise, onResolve, onReject, resultCapability) { |
@@ -629,14 +641,11 @@ utils.InstallFunctions(extrasUtils, 0, [ |
fn => %FunctionRemovePrototype(fn)); |
utils.Export(function(to) { |
- to.IsPromise = IsPromise; |
- |
to.PromiseChain = PromiseChain; |
to.PromiseDefer = PromiseDefer; |
to.PromiseAccept = PromiseAccept; |
- to.PromiseCreateRejected = PromiseCreateRejected; |
- to.PromiseCreateResolved = PromiseCreateResolved; |
+ to.PromiseCastResolved = PromiseCastResolved; |
to.PromiseThen = PromiseThen; |
to.GlobalPromise = GlobalPromise; |