2023-06-12 17:45:27 +00:00
|
|
|
/**
|
|
|
|
* @typedef {object} Replacement
|
|
|
|
* @property {string | RegExp} pattern
|
|
|
|
* @property {string} replacement
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {Array<Replacement>} Replacements
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2024-06-09 21:53:52 +00:00
|
|
|
* @param {String} rawContent
|
2023-06-12 17:45:27 +00:00
|
|
|
* @param {Replacements} replacements
|
|
|
|
*/
|
2024-06-09 21:53:52 +00:00
|
|
|
module.exports = function (rawContent, replacements) {
|
|
|
|
let content = rawContent;
|
2023-06-12 18:20:11 +00:00
|
|
|
replacements.forEach(replacement => {
|
2024-06-09 21:53:52 +00:00
|
|
|
content = content.replaceAll(replacement.pattern, replacement.replacement);
|
2023-06-12 18:20:11 +00:00
|
|
|
});
|
2024-06-09 21:53:52 +00:00
|
|
|
|
|
|
|
return content;
|
2023-06-12 18:20:11 +00:00
|
|
|
};
|