Closed miguelmota closed 8 years ago
Actually, it seems that this is correct. Because value of new Uint8ClampedArray(3)
seems like object to me. I'm not sure what is the correct behaving here.
We can add few checks
if (val instanceof Array) {
return 'array';
}
and something like that
if (type.indexOf('Array') !== -1) {
return 'array';
}
which will handle this "issue".
My suggestion for typed arrays
var obj = new Uint8ClampedArray(1);
var typedArrayTypes = ['Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array'];
var typeString = Object.prototype.toString.call(obj).match(/\s+(\w+)/i)[1];
var typeIndex = typedArrayTypes.indexOf(typeString);
if (typeIndex > -1) {
console.log(typeString.toLowerCase()); // uint8clampedarray
}
I think we should return array
, imo.
That doesn't seem like the right thing to do considering that typed arrays are there own types, like Map and Set
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures
(new Uint8ClampedArray(1)) instanceof Array // false
I believe this is resolved
Shouldn't it be
Uint8ClampedArray
?