Remove replaceAsync() dependency on String.prototype.matchAll().
This commit is contained in:
parent
28972ba44f
commit
fae6b04131
|
@ -145,9 +145,13 @@
|
||||||
async getContentCSS() {
|
async getContentCSS() {
|
||||||
contentCSS = contentCSS || (async () => {
|
contentCSS = contentCSS || (async () => {
|
||||||
const replaceAsync = async (string, regexp, replacerFunction) => {
|
const replaceAsync = async (string, regexp, replacerFunction) => {
|
||||||
const replacements = await Promise.all(
|
regexp.lastIndex = 0;
|
||||||
Array.from(string.matchAll(regexp),
|
const promises = [];
|
||||||
match => replacerFunction(...match)));
|
for (let match; match = regexp.exec(string);) {
|
||||||
|
promises.push(replacerFunction(...match));
|
||||||
|
}
|
||||||
|
const replacements = await Promise.all(promises);
|
||||||
|
regexp.lastIndex = 0;
|
||||||
let i = 0;
|
let i = 0;
|
||||||
return string.replace(regexp, () => replacements[i++]);
|
return string.replace(regexp, () => replacements[i++]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue