UNPKG

html-minifier-terser

Version:

Highly configurable, well-tested, JavaScript-based HTML minifier.

12 lines (9 loc) 300 B
export async function replaceAsync(str, regex, asyncFn) { const promises = []; str.replace(regex, (match, ...args) => { const promise = asyncFn(match, ...args); promises.push(promise); }); const data = await Promise.all(promises); return str.replace(regex, () => data.shift()); }