diff --git a/src/functions/util/splitText.js b/src/functions/util/splitText.js index 95e104635..e821e8b3a 100644 --- a/src/functions/util/splitText.js +++ b/src/functions/util/splitText.js @@ -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) diff --git a/src/functions/util/textSplit.js b/src/functions/util/textSplit.js index 1aa57f83b..4dfd62caa 100644 --- a/src/functions/util/textSplit.js +++ b/src/functions/util/textSplit.js @@ -1,9 +1,10 @@ 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 { @@ -11,4 +12,4 @@ module.exports = d => { data: d.data, array: d.array, } -} +} \ No newline at end of file