| | |
| | | 'use strict'; |
| | | var $ = require('../internals/export'); |
| | | var IS_PURE = require('../internals/is-pure'); |
| | | var NativePromise = require('../internals/native-promise-constructor'); |
| | | var NativePromiseConstructor = require('../internals/promise-native-constructor'); |
| | | var fails = require('../internals/fails'); |
| | | var getBuiltIn = require('../internals/get-built-in'); |
| | | var isCallable = require('../internals/is-callable'); |
| | | var speciesConstructor = require('../internals/species-constructor'); |
| | | var promiseResolve = require('../internals/promise-resolve'); |
| | | var redefine = require('../internals/redefine'); |
| | | var defineBuiltIn = require('../internals/define-built-in'); |
| | | |
| | | var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype; |
| | | |
| | | // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829 |
| | | var NON_GENERIC = !!NativePromise && fails(function () { |
| | | NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ }); |
| | | var NON_GENERIC = !!NativePromiseConstructor && fails(function () { |
| | | // eslint-disable-next-line unicorn/no-thenable -- required for testing |
| | | NativePromisePrototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ }); |
| | | }); |
| | | |
| | | // `Promise.prototype.finally` method |
| | |
| | | }); |
| | | |
| | | // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then` |
| | | if (!IS_PURE && isCallable(NativePromise)) { |
| | | if (!IS_PURE && isCallable(NativePromiseConstructor)) { |
| | | var method = getBuiltIn('Promise').prototype['finally']; |
| | | if (NativePromise.prototype['finally'] !== method) { |
| | | redefine(NativePromise.prototype, 'finally', method, { unsafe: true }); |
| | | if (NativePromisePrototype['finally'] !== method) { |
| | | defineBuiltIn(NativePromisePrototype, 'finally', method, { unsafe: true }); |
| | | } |
| | | } |