MES手机端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
618 B

  1. 'use strict';
  2. var aCallable = require('../internals/a-callable');
  3. var $TypeError = TypeError;
  4. var PromiseCapability = function (C) {
  5. var resolve, reject;
  6. this.promise = new C(function ($$resolve, $$reject) {
  7. if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor');
  8. resolve = $$resolve;
  9. reject = $$reject;
  10. });
  11. this.resolve = aCallable(resolve);
  12. this.reject = aCallable(reject);
  13. };
  14. // `NewPromiseCapability` abstract operation
  15. // https://tc39.es/ecma262/#sec-newpromisecapability
  16. module.exports.f = function (C) {
  17. return new PromiseCapability(C);
  18. };