Skip to content

Commit

Permalink
feat: advancedReplaceText[]
Browse files Browse the repository at this point in the history
  • Loading branch information
Faf4a committed Mar 25, 2024
1 parent 2f720a8 commit f5c4568
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/functions/util/advancedReplaceText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = async (d) => {
const data = d.util.aoiFunc(d);
if (data.err) return d.error(data.err);

const [...replace] = data.inside.splits;
let [text, ...replacements] = replace;

for (let i = 0; i < replacements.length; i += 2) {
const replacer = replacements[i];
const replaceTo = replacements[i + 1];
text = text.replaceAll(replacer.addBrackets(), replaceTo.addBrackets());
}

data.result = text.addBrackets();

return {
code: d.util.setCode(data)
};
};

0 comments on commit f5c4568

Please sign in to comment.