UNPKG

605 BJavaScriptView Raw
1/**
2 * String.prototype.replaceAll() polyfill
3 * https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/
4 * @author Chris Ferdinandi
5 * @license MIT
6 */
7if (!String.prototype.replaceAll) {
8 String.prototype.replaceAll = function (str, newStr) {
9 // If a regex pattern
10 if (Object.prototype.toString.call(str).toLowerCase() === "[object regexp]") {
11 return this.replace(str, newStr);
12 }
13 // If a string
14 return this.replace(new RegExp(str, "g"), newStr);
15 };
16}
17export {};
18//# sourceMappingURL=_dnt.polyfills.js.map
\No newline at end of file