promise-resolve.js 441 B

12345678910111213
  1. 'use strict';
  2. var anObject = require('../internals/an-object');
  3. var isObject = require('../internals/is-object');
  4. var newPromiseCapability = require('../internals/new-promise-capability');
  5. module.exports = function (C, x) {
  6. anObject(C);
  7. if (isObject(x) && x.constructor === C) return x;
  8. var promiseCapability = newPromiseCapability.f(C);
  9. var resolve = promiseCapability.resolve;
  10. resolve(x);
  11. return promiseCapability.promise;
  12. };