source: trip-planner-front/node_modules/icss-utils/src/replaceValueSymbols.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 502 bytes
RevLine 
[6a3a178]1const matchValueName = /[$]?[\w-]+/g;
2
3const replaceValueSymbols = (value, replacements) => {
4 let matches;
5
6 while ((matches = matchValueName.exec(value))) {
7 const replacement = replacements[matches[0]];
8
9 if (replacement) {
10 value =
11 value.slice(0, matches.index) +
12 replacement +
13 value.slice(matchValueName.lastIndex);
14
15 matchValueName.lastIndex -= matches[0].length - replacement.length;
16 }
17 }
18
19 return value;
20};
21
22module.exports = replaceValueSymbols;
Note: See TracBrowser for help on using the repository browser.