Why join and then split again, eh? - Refactor /add actually using the array provided as the array for the internal `parseNumericSeries` inside `performOperation`

0d38e634714ccb254799b390293066e54912bc37

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +5 -6Ignore whitespace
public/scripts/variables.js+5 -6
@@ -669,8 +669,8 @@ function deleteGlobalVariable(name) {
669669}
670670
671671/**
672672 * Parses a series of numeric values from a string or a string array.
673673 * @param {string|string[]} value A space-separated list of numeric values or variable names
674674 * @param {SlashCommandScope} scope Scope
675675 * @returns {number[]} An array of numeric values
676676 */
@@ -679,9 +679,8 @@ function parseNumericSeries(value, scope = null) {
679679 return [value];
680680 }
681681
682- const array = value
682+ const values = Array.isArray(value) ? value : value.split(' ');
683- .split(' ')
683+ const array = values.map(i => i.trim())
684- .map(i => i.trim())
685684 .filter(i => i !== '')
686685 .map(i => isNaN(Number(i)) ? Number(resolveVariable(i, scope)) : Number(i))
687686 .filter(i => !isNaN(i));
@@ -1595,7 +1594,7 @@ export function registerVariableCommands() {
15951594 }));
15961595 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
15971596 name: 'add',
15981597 callback: (args, /**@type {string[]}*/value) => addValuesCallback(args, value.join(' ')),
15991598 returns: 'sum of the provided values',
16001599 unnamedArgumentList: [
16011600 SlashCommandArgument.fromProps({