New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use with typed arrays #4920
Comments
There are 2 problems
Array.isArray(new Float32Array())
false
Array.isArray(new Array())
true A rudimentary fix could be adding a check for typed arrays. isTypedArray: function(value) {
var type = Object.prototype.toString.call(value);
return type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]';
},
each: function(loopable, fn, thisArg, reverse) {
var i, len, keys;
if (helpers.isArray(loopable) || helpers.isTypedArray(loopable)) { Or maybe it would be better to adopt the JQuery implementation |
@etimberg any thoughts on a preferred implementation for type arrays? |
I have no preference for with solution. Both work for me |
I like your method for checking for typed array better than jquery's, but think it makes sense to encapsulate inside
|
@benmccann I'm afraid your code won't work, as it would return Browser compatibility Array.isArray
I still think it would be better to implement a separate function /**
* Returns true if `value` is a typed array, else returns false.
* @param {*} value - The value to test.
* @returns {Boolean}
* @function
*/
isTypedArray: function(value) {
var type = Object.prototype.toString.call(value);
return type.substr(1, 6) === 'object' && type.substr(-6, 5) === 'Array' && value.byteLength !== undefined;
} |
I would start with |
@jcopperfield yeah, I was a bit hasty. I've updated the suggestion to account for the issue you mentioned |
@benmccann it still doesn't work because Safer to define a new method. |
you're right. I've updated again We have a couple dozen places where we call I'm not in love with the name |
I'm not fan either of the If you can guarantee that changing the behavior of |
Hi developers,
I am facing an issue after upgrading from v2.6.0 to v2.7.0. The charts are not working with typed arrays. Here is a JSFiddle example
https://jsfiddle.net/fwb415nw/1/
The text was updated successfully, but these errors were encountered: