_new-promise-capability.js 504 B

123456789101112131415161718
  1. 'use strict';
  2. // 25.4.1.5 NewPromiseCapability(C)
  3. var aFunction = require('./_a-function');
  4. function PromiseCapability(C) {
  5. var resolve, reject;
  6. this.promise = new C(function ($$resolve, $$reject) {
  7. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  8. resolve = $$resolve;
  9. reject = $$reject;
  10. });
  11. this.resolve = aFunction(resolve);
  12. this.reject = aFunction(reject);
  13. }
  14. module.exports.f = function (C) {
  15. return new PromiseCapability(C);
  16. };