source: imaps-frontend/node_modules/html-minifier-terser/src/utils.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 754 bytes
Line 
1'use strict';
2
3function createMap(values, ignoreCase) {
4 var map = {};
5 values.forEach(function(value) {
6 map[value] = 1;
7 });
8 return ignoreCase ? function(value) {
9 return map[value.toLowerCase()] === 1;
10 } : function(value) {
11 return map[value] === 1;
12 };
13}
14
15async function replaceAsync(str, regex, asyncFn) {
16 const promises = [];
17 str.replace(regex, (match, ...args) => {
18 const promise = asyncFn(match, ...args);
19 promises.push(promise);
20 });
21 const data = await Promise.all(promises);
22 return str.replace(regex, () => data.shift());
23}
24
25
26exports.createMap = createMap;
27exports.createMapFromString = function(values, ignoreCase) {
28 return createMap(values.split(/,/), ignoreCase);
29};
30
31exports.replaceAsync = replaceAsync;
Note: See TracBrowser for help on using the repository browser.