Relax strictness to allow arraylike containers too

This commit is contained in:
GoToLoop 2017-10-31 23:49:52 -02:00 committed by GitHub
parent 2659494a80
commit fbd46518c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,7 +65,8 @@ const Common = {
return; return;
} }
if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) { //if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
if (obj.forEach) {
obj.forEach(itr, scope); obj.forEach(itr, scope);
} else if (obj.length === obj.length + 0) { // Is number but not NaN } else if (obj.length === obj.length + 0) { // Is number but not NaN
let key; let key;
@ -128,8 +129,10 @@ const Common = {
return isNaN(obj); return isNaN(obj);
}, },
isArray: Array.isArray || function(obj) { //isArray: Array.isArray || function(obj) {
return obj.constructor === Array; isArray: function(obj) {
//return obj.constructor === Array;
return obj && obj.length >= 0 && typeof obj === 'object';
}, },
isObject: function(obj) { isObject: function(obj) {