Skip to content

Commit

Permalink
Add Name Option To $TextSplit & $SplitText
Browse files Browse the repository at this point in the history
  • Loading branch information
NezitX committed Nov 6, 2023
1 parent 1512650 commit 50709d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/functions/util/splitText.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module.exports = d => {
const data = d.util.aoiFunc(d);
if (data.err) return d.error(data.err);

const [index] = data.inside.splits;
const [name, index] = data.inside.splits;

if (isNaN(index) || Number(index) < 1) return d.aoiError.fnError(d, 'custom', {inside: data.inside}, 'Invalid Index Provided In');
if (isNaN(index) || Number(index) < 1) return d.aoiError.fnError(d, 'custom', { inside: data.inside }, 'Invalid Index Provided In');
if (!name) return d.aoiError.fnError(d, 'custom', { inside: data.inside }, 'Invalid Name Provided In');

data.result = d.array[Number(index) - 1];
data.result = d.array[name][Number(index) - 1];

return {
code: d.util.setCode(data)
Expand Down
7 changes: 4 additions & 3 deletions src/functions/util/textSplit.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module.exports = d => {
const data = d.util.aoiFunc(d);

let [text, sep = ' '] = data.inside.splits;
let [name, text, sep = ' '] = data.inside.splits;
if (!name) return d.aoiError.fnError(d, 'custom', { inside: data.inside }, 'Invalid Name Provided In');

d.array = text.addBrackets().split(sep.addBrackets());
d.array[name] = text.addBrackets().split(sep.addBrackets());
d.data.array = d.array;

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

0 comments on commit 50709d9

Please sign in to comment.