All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.modules.esnext.promise.try.js Maven / Gradle / Ivy

There is a newer version: 3.39.0
Show newest version
'use strict';
// TODO: Remove from `core-js@4`
var $ = require('../internals/export');
var newPromiseCapabilityModule = require('../internals/new-promise-capability');
var perform = require('../internals/perform');

// `Promise.try` method
// https://github.com/tc39/proposal-promise-try
$({ target: 'Promise', stat: true, forced: true }, {
  'try': function (callbackfn) {
    var promiseCapability = newPromiseCapabilityModule.f(this);
    var result = perform(callbackfn);
    (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
    return promiseCapability.promise;
  }
});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy