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

Side by Side Diff: src/js/promise.js

Issue 1538853002: [promise] use PromiseCapabilities directly for Promise.race resolve/reject (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased again Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils, extrasUtils) { 5 (function(global, utils, extrasUtils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 387 }
388 388
389 function PromiseRace(iterable) { 389 function PromiseRace(iterable) {
390 if (!IS_RECEIVER(this)) { 390 if (!IS_RECEIVER(this)) {
391 throw MakeTypeError(kCalledOnNonObject, PromiseRace); 391 throw MakeTypeError(kCalledOnNonObject, PromiseRace);
392 } 392 }
393 393
394 var deferred = NewPromiseCapability(this); 394 var deferred = NewPromiseCapability(this);
395 try { 395 try {
396 for (var value of iterable) { 396 for (var value of iterable) {
397 var reject = reason => { deferred.reject(reason); }; 397 this.resolve(value).then(deferred.resolve, deferred.reject);
398 this.resolve(value).then((x) => { deferred.resolve(x) }, reject); 398 SET_PRIVATE(deferred.reject, promiseCombinedDeferredSymbol, deferred);
399 SET_PRIVATE(reject, promiseCombinedDeferredSymbol, deferred);
400 } 399 }
401 } catch (e) { 400 } catch (e) {
402 deferred.reject(e) 401 deferred.reject(e)
403 } 402 }
404 return deferred.promise; 403 return deferred.promise;
405 } 404 }
406 405
407 406
408 // Utility for debugger 407 // Utility for debugger
409 408
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( 474 [PromiseChain, PromiseDeferred, PromiseResolved].forEach(
476 fn => %FunctionRemovePrototype(fn)); 475 fn => %FunctionRemovePrototype(fn));
477 476
478 utils.Export(function(to) { 477 utils.Export(function(to) {
479 to.PromiseChain = PromiseChain; 478 to.PromiseChain = PromiseChain;
480 to.PromiseDeferred = PromiseDeferred; 479 to.PromiseDeferred = PromiseDeferred;
481 to.PromiseResolved = PromiseResolved; 480 to.PromiseResolved = PromiseResolved;
482 }); 481 });
483 482
484 }) 483 })
OLDNEW
« no previous file with comments | « no previous file | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698