_promise-resolve.js 397 B

123456789101112
  1. var anObject = require('./_an-object');
  2. var isObject = require('./_is-object');
  3. var newPromiseCapability = require('./_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. };