replaceValueSymbols.js 606 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. const matchValueName = /[$]?[\w-]+/g;
  7. const replaceValueSymbols = (value, replacements) => {
  8. let matches;
  9. while (matches = matchValueName.exec(value)) {
  10. const replacement = replacements[matches[0]];
  11. if (replacement) {
  12. value = value.slice(0, matches.index) + replacement + value.slice(matchValueName.lastIndex);
  13. matchValueName.lastIndex -= matches[0].length - replacement.length;
  14. }
  15. }
  16. return value;
  17. };
  18. var _default = replaceValueSymbols;
  19. exports.default = _default;