GetPromiseResolve.js 692 B

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