UNPKG

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