Last active
November 15, 2020 21:19
-
-
Save developit/e96097d9b657f2a2f3e588ffde433437 to your computer and use it in GitHub Desktop.
polyfill ES2018 standard library stuff for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!('trimStart' in String.prototype)) String.prototype.trimStart = String.prototype.trimLeft; | |
if (!('trimEnd' in String.prototype)) String.prototype.trimEnd = String.prototype.trimRight; | |
if (!('forEach' in NodeList.prototype)) NodeList.prototype.forEach = [].forEach; | |
if (!('description' in Symbol.prototype)) { | |
Object.defineProperty(Symbol.prototype, 'description', { | |
get() { return /\((.+)\)/.exec(this)[1] } | |
}); | |
} | |
if (!('finally' in Promise.prototype)) { | |
Promise.prototype.finally = function(t){if("function"!=typeof t)return this.then(t,t);const e=this.constructor||Promise;return this.then(o=>e.resolve(t()).then(()=>o),o=>e.resolve(t()).then(()=>{throw o}))}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment