mirror of https://github.com/jkjoy/sunpeiwen.git
13 lines
477 B
JavaScript
13 lines
477 B
JavaScript
'use strict';
|
|
// https://github.com/tc39/proposal-promise-try
|
|
var $export = require('./_export');
|
|
var newPromiseCapability = require('./_new-promise-capability');
|
|
var perform = require('./_perform');
|
|
|
|
$export($export.S, 'Promise', { 'try': function (callbackfn) {
|
|
var promiseCapability = newPromiseCapability.f(this);
|
|
var result = perform(callbackfn);
|
|
(result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
|
|
return promiseCapability.promise;
|
|
} });
|