Skip to content

Commit a25ff13

Browse files
committed
accept typed array when coercing 'data_array' attributes
1 parent 91b03ff commit a25ff13

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/coerce.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@ var nestedProperty = require('./nested_property');
1919
var counterRegex = require('./regex').counter;
2020
var DESELECTDIM = require('../constants/interactions').DESELECTDIM;
2121
var wrap180 = require('./angles').wrap180;
22+
var isArrayOrTypedArray = require('./is_array').isArrayOrTypedArray;
2223

2324
exports.valObjectMeta = {
2425
data_array: {
2526
// You can use *dflt=[] to force said array to exist though.
2627
description: [
2728
'An {array} of data.',
28-
'The value MUST be an {array}, or we ignore it.'
29+
'The value MUST be an {array}, or we ignore it.',
30+
'Note that typed arrays (e.g. Float32Array) are supported.'
2931
].join(' '),
3032
requiredOpts: [],
3133
otherOpts: ['dflt'],
3234
coerceFunction: function(v, propOut, dflt) {
33-
if(Array.isArray(v)) propOut.set(v);
35+
if(isArrayOrTypedArray(v)) propOut.set(v);
3436
else if(dflt !== undefined) propOut.set(dflt);
3537
}
3638
},

0 commit comments

Comments
 (0)