UNPKG

@omnigraph/neo4j

Version:

26 lines (25 loc) 1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.revertStrReplaceAllPolyfill = exports.polyfillStrReplaceAll = void 0; let strReplaceAllPolyfilled = false; function polyfillStrReplaceAll() { if (!String.prototype.replaceAll) { strReplaceAllPolyfilled = true; // eslint-disable-next-line no-extend-native String.prototype.replaceAll = function (str, newStr) { if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') { return this.replace(str, newStr); } return this.replace(new RegExp(str, 'g'), newStr); }; } } exports.polyfillStrReplaceAll = polyfillStrReplaceAll; function revertStrReplaceAllPolyfill() { if (strReplaceAllPolyfilled) { strReplaceAllPolyfilled = false; // eslint-disable-next-line no-extend-native delete String.prototype.replaceAll; } } exports.revertStrReplaceAllPolyfill = revertStrReplaceAllPolyfill;