1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-11 16:18:10 +00:00

data/TrialHandler: fix attempted destructuring on non arrays

When calling `Util.turnSquareBracketsIntoArrays()`, forget
about destructuring ahead of checking whether the result
is an array, just take the first element if it is.
This commit is contained in:
Sotiri Bakagiannis 2020-09-07 18:19:58 +01:00
parent 6523a4a404
commit 968070436a

View File

@ -473,11 +473,15 @@ export class TrialHandler extends PsychObject
value = Number.parseFloat(value);
}
const [arrayMaybe] = util.turnSquareBracketsIntoArrays(value);
// Look for string encoded arrays in the form of '[1, 2]'
const arrayMaybe = util.turnSquareBracketsIntoArrays(value);
if (Array.isArray(arrayMaybe))
{
value = arrayMaybe;
// Keep the first match if more than one are found. If the
// input string looked like '[1, 2][3, 4]' for example,
// the resulting value would be [1, 2]
value = arrayMaybe[0];
}
trial[fields[l]] = value;