source: trip-planner-front/node_modules/core-js/modules/es.promise.finally.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var IS_PURE = require('../internals/is-pure');
4var NativePromise = require('../internals/native-promise-constructor');
5var fails = require('../internals/fails');
6var getBuiltIn = require('../internals/get-built-in');
7var speciesConstructor = require('../internals/species-constructor');
8var promiseResolve = require('../internals/promise-resolve');
9var redefine = require('../internals/redefine');
10
11// Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
12var NON_GENERIC = !!NativePromise && fails(function () {
13 NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
14});
15
16// `Promise.prototype.finally` method
17// https://tc39.es/ecma262/#sec-promise.prototype.finally
18$({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
19 'finally': function (onFinally) {
20 var C = speciesConstructor(this, getBuiltIn('Promise'));
21 var isFunction = typeof onFinally == 'function';
22 return this.then(
23 isFunction ? function (x) {
24 return promiseResolve(C, onFinally()).then(function () { return x; });
25 } : onFinally,
26 isFunction ? function (e) {
27 return promiseResolve(C, onFinally()).then(function () { throw e; });
28 } : onFinally
29 );
30 }
31});
32
33// makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
34if (!IS_PURE && typeof NativePromise == 'function') {
35 var method = getBuiltIn('Promise').prototype['finally'];
36 if (NativePromise.prototype['finally'] !== method) {
37 redefine(NativePromise.prototype, 'finally', method, { unsafe: true });
38 }
39}
Note: See TracBrowser for help on using the repository browser.