OLD | NEW |
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 Loading... |
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 Loading... |
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 }) |
OLD | NEW |