source: imaps-frontend/node_modules/core-js/modules/es.promise.try.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[79a0317]1'use strict';
2var $ = require('../internals/export');
3var globalThis = require('../internals/global-this');
4var apply = require('../internals/function-apply');
5var slice = require('../internals/array-slice');
6var newPromiseCapabilityModule = require('../internals/new-promise-capability');
7var aCallable = require('../internals/a-callable');
8var perform = require('../internals/perform');
9
10var Promise = globalThis.Promise;
11
12var ACCEPT_ARGUMENTS = false;
13// Avoiding the use of polyfills of the previous iteration of this proposal
14// that does not accept arguments of the callback
15var FORCED = !Promise || !Promise['try'] || perform(function () {
16 Promise['try'](function (argument) {
17 ACCEPT_ARGUMENTS = argument === 8;
18 }, 8);
19}).error || !ACCEPT_ARGUMENTS;
20
21// `Promise.try` method
22// https://tc39.es/ecma262/#sec-promise.try
23$({ target: 'Promise', stat: true, forced: FORCED }, {
24 'try': function (callbackfn /* , ...args */) {
25 var args = arguments.length > 1 ? slice(arguments, 1) : [];
26 var promiseCapability = newPromiseCapabilityModule.f(this);
27 var result = perform(function () {
28 return apply(aCallable(callbackfn), undefined, args);
29 });
30 (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
31 return promiseCapability.promise;
32 }
33});
Note: See TracBrowser for help on using the repository browser.