promise-resolve.js 427 B

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