Sha256: a183c20d71ca3b30d9d0db09f09a4c7843ee233249adc97c2da9f5b9d819e8e1

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

'use strict';
var $ = require('../internals/export');
var IS_PURE = require('../internals/is-pure');
var NativePromise = require('../internals/native-promise-constructor');
var fails = require('../internals/fails');
var getBuiltIn = require('../internals/get-built-in');
var speciesConstructor = require('../internals/species-constructor');
var promiseResolve = require('../internals/promise-resolve');
var redefine = require('../internals/redefine');

// 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 */ });
});

// `Promise.prototype.finally` method
// https://tc39.github.io/ecma262/#sec-promise.prototype.finally
$({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
  'finally': function (onFinally) {
    var C = speciesConstructor(this, getBuiltIn('Promise'));
    var isFunction = typeof onFinally == 'function';
    return this.then(
      isFunction ? function (x) {
        return promiseResolve(C, onFinally()).then(function () { return x; });
      } : onFinally,
      isFunction ? function (e) {
        return promiseResolve(C, onFinally()).then(function () { throw e; });
      } : onFinally
    );
  }
});

// patch native Promise.prototype for native async functions
if (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) {
  redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);
}

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/core-js/modules/es.promise.finally.js
tang-0.2.1 spec/tang_app/node_modules/core-js/modules/es.promise.finally.js
tang-0.2.0 spec/tang_app/node_modules/core-js/modules/es.promise.finally.js
tang-0.1.0 spec/tang_app/node_modules/core-js/modules/es.promise.finally.js
tang-0.0.9 spec/tang_app/node_modules/core-js/modules/es.promise.finally.js
enju_library-0.3.8 spec/dummy/node_modules/core-js/modules/es.promise.finally.js
condenser-0.3 lib/condenser/processors/node_modules/core-js-pure/modules/es.promise.finally.js
condenser-0.2 lib/condenser/processors/node_modules/core-js-pure/modules/es.promise.finally.js
condenser-0.1 lib/condenser/processors/node_modules/core-js-pure/modules/es.promise.finally.js
condenser-0.0.12 lib/condenser/processors/node_modules/core-js-pure/modules/es.promise.finally.js
condenser-0.0.11 lib/condenser/processors/node_modules/core-js-pure/modules/es.promise.finally.js
condenser-0.0.10 lib/condenser/processors/node_modules/core-js-pure/modules/es.promise.finally.js
condenser-0.0.9 lib/condenser/processors/node_modules/core-js-pure/modules/es.promise.finally.js