Skip to content

Commit

Permalink
add support for typed arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Dec 10, 2018
1 parent 69fcba0 commit 2e322a0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/helpers/helpers.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ var helpers = {
},

/**
* Returns true if `value` is an array, else returns false.
* Returns true if `value` is an array (including typed arrays), else returns false.
* @param {*} value - The value to test.
* @returns {Boolean}
* @function
*/
isArray: Array.isArray ? Array.isArray : function(value) {
return Object.prototype.toString.call(value) === '[object Array]';
isArray: function(value) {
var type = Object.prototype.toString.call(value);
// Typed array
if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') {
return true;
}
if (Array.isArray) {
return Array.isArray(value);
}
return type === '[object Array]';
},

/**
Expand Down

0 comments on commit 2e322a0

Please sign in to comment.