aboutsummaryrefslogtreecommitdiff
path: root/node_modules/core-js/modules/es7.promise.finally.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/core-js/modules/es7.promise.finally.js')
-rw-r--r--node_modules/core-js/modules/es7.promise.finally.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/node_modules/core-js/modules/es7.promise.finally.js b/node_modules/core-js/modules/es7.promise.finally.js
new file mode 100644
index 000000000..fa04b6399
--- /dev/null
+++ b/node_modules/core-js/modules/es7.promise.finally.js
@@ -0,0 +1,20 @@
+// https://github.com/tc39/proposal-promise-finally
+'use strict';
+var $export = require('./_export');
+var core = require('./_core');
+var global = require('./_global');
+var speciesConstructor = require('./_species-constructor');
+var promiseResolve = require('./_promise-resolve');
+
+$export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
+ var C = speciesConstructor(this, core.Promise || global.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
+ );
+} });