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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 }; | 439 }; |
440 | 440 |
441 // ------------------------------------------------------------------- | 441 // ------------------------------------------------------------------- |
442 // Install exported functions. | 442 // Install exported functions. |
443 | 443 |
444 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM); | 444 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM); |
445 %AddNamedProperty(GlobalPromise.prototype, toStringTagSymbol, "Promise", | 445 %AddNamedProperty(GlobalPromise.prototype, toStringTagSymbol, "Promise", |
446 DONT_ENUM | READ_ONLY); | 446 DONT_ENUM | READ_ONLY); |
447 | 447 |
448 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ | 448 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ |
| 449 "defer", PromiseDeferred, |
| 450 "accept", PromiseResolved, |
449 "reject", PromiseRejected, | 451 "reject", PromiseRejected, |
450 "all", PromiseAll, | 452 "all", PromiseAll, |
451 "race", PromiseRace, | 453 "race", PromiseRace, |
452 "resolve", PromiseCast | 454 "resolve", PromiseCast |
453 ]); | 455 ]); |
454 | 456 |
455 utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [ | 457 utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [ |
| 458 "chain", PromiseChain, |
456 "then", PromiseThen, | 459 "then", PromiseThen, |
457 "catch", PromiseCatch | 460 "catch", PromiseCatch |
458 ]); | 461 ]); |
459 | 462 |
460 %InstallToContext([ | 463 %InstallToContext([ |
461 "promise_catch", PromiseCatch, | 464 "promise_catch", PromiseCatch, |
| 465 "promise_chain", PromiseChain, |
462 "promise_create", PromiseCreate, | 466 "promise_create", PromiseCreate, |
463 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, | 467 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, |
464 "promise_reject", PromiseReject, | 468 "promise_reject", PromiseReject, |
465 "promise_resolve", PromiseResolve, | 469 "promise_resolve", PromiseResolve, |
466 "promise_then", PromiseThen, | 470 "promise_then", PromiseThen, |
467 ]); | 471 ]); |
468 | 472 |
469 // This allows extras to create promises quickly without building extra | 473 // This allows extras to create promises quickly without building extra |
470 // resolve/reject closures, and allows them to later resolve and reject any | 474 // resolve/reject closures, and allows them to later resolve and reject any |
471 // promise without having to hold on to those closures forever. | 475 // promise without having to hold on to those closures forever. |
472 utils.InstallFunctions(extrasUtils, 0, [ | 476 utils.InstallFunctions(extrasUtils, 0, [ |
473 "createPromise", PromiseCreate, | 477 "createPromise", PromiseCreate, |
474 "resolvePromise", PromiseResolve, | 478 "resolvePromise", PromiseResolve, |
475 "rejectPromise", PromiseReject | 479 "rejectPromise", PromiseReject |
476 ]); | 480 ]); |
477 | 481 |
478 // TODO(v8:4567): Allow experimental natives to remove function prototype | |
479 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( | |
480 fn => %FunctionRemovePrototype(fn)); | |
481 | |
482 utils.Export(function(to) { | |
483 to.PromiseChain = PromiseChain; | |
484 to.PromiseDeferred = PromiseDeferred; | |
485 to.PromiseResolved = PromiseResolved; | |
486 }); | |
487 | |
488 }) | 482 }) |
OLD | NEW |