GetPromiseResolve.js 639 B

1234567891011121314151617181920
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var Get = require('./Get');
  4. var IsCallable = require('./IsCallable');
  5. var IsConstructor = require('./IsConstructor');
  6. // https://262.ecma-international.org/12.0/#sec-getpromiseresolve
  7. module.exports = function GetPromiseResolve(promiseConstructor) {
  8. if (!IsConstructor(promiseConstructor)) {
  9. throw new $TypeError('Assertion failed: `promiseConstructor` must be a constructor');
  10. }
  11. var promiseResolve = Get(promiseConstructor, 'resolve');
  12. if (IsCallable(promiseResolve) === false) {
  13. throw new $TypeError('`resolve` method is not callable');
  14. }
  15. return promiseResolve;
  16. };