Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: src/promise.js

Issue 200763012: Remove Promise.cast (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/es6/promises.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index f6b7bdff4b29a7af90b3d2ce21bd2712f3752e59..8947670f0669617a4048350848a9a5419bde10e7 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -261,7 +261,7 @@ function PromiseCoerce(constructor, x) {
function PromiseCast(x) {
// TODO(rossberg): cannot do better until we support @@create.
- return IsPromise(x) ? x : this.resolve(x);
+ return IsPromise(x) ? x : new this(function(resolve) { resolve(x) });
}
function PromiseAll(values) {
@@ -277,7 +277,7 @@ function PromiseAll(values) {
deferred.resolve(resolutions);
} else {
for (var i = 0; i < values.length; ++i) {
- this.cast(values[i]).then(
+ this.resolve(values[i]).then(
function(i, x) {
resolutions[i] = x;
if (--count === 0) deferred.resolve(resolutions);
@@ -300,7 +300,7 @@ function PromiseOne(values) {
}
try {
for (var i = 0; i < values.length; ++i) {
- this.cast(values[i]).then(
+ this.resolve(values[i]).then(
function(x) { deferred.resolve(x) },
function(r) { deferred.reject(r) }
);
@@ -319,11 +319,11 @@ function SetUpPromise() {
global_receiver.Promise = $Promise;
InstallFunctions($Promise, DONT_ENUM, [
"defer", PromiseDeferred,
- "resolve", PromiseResolved,
+ "accept", PromiseResolved,
"reject", PromiseRejected,
"all", PromiseAll,
"race", PromiseOne,
- "cast", PromiseCast
+ "resolve", PromiseCast
]);
InstallFunctions($Promise.prototype, DONT_ENUM, [
"chain", PromiseChain,
« no previous file with comments | « no previous file | test/mjsunit/es6/promises.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698