paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 388 forks source link

Promise shim missing finally method #472

Closed darxis closed 2 years ago

darxis commented 2 years ago

I am using es6-shim on some old Android device and I am experiencing errors when trying to call Promise.finally:

Object # has no method 'finally'

The following code outputs catch,then,constructor on my old Android device and outputs catch,then,finally,constructor on a modern PC browser.

let promise = ...;
alert(Object.getOwnPropertyNames(Object.getPrototypeOf(promise)).join(','));

It seems that Promise.finally has not been implemented yet?

ljharb commented 2 years ago

It's not missing - the method isn't in ES6, it was added in ES2018.

Use https://www.npmjs.com/package/promise.prototype.finally to shim it, on top of the es6-shim.