es7.promise.try.js 477 B

123456789101112
  1. 'use strict';
  2. // https://github.com/tc39/proposal-promise-try
  3. var $export = require('./_export');
  4. var newPromiseCapability = require('./_new-promise-capability');
  5. var perform = require('./_perform');
  6. $export($export.S, 'Promise', { 'try': function (callbackfn) {
  7. var promiseCapability = newPromiseCapability.f(this);
  8. var result = perform(callbackfn);
  9. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  10. return promiseCapability.promise;
  11. } });