From fbd46518c5b8e37fdffb1c8f1e7cc6d3d232a6b8 Mon Sep 17 00:00:00 2001 From: GoToLoop Date: Tue, 31 Oct 2017 23:49:52 -0200 Subject: [PATCH] Relax strictness to allow arraylike containers too --- src/dat/utils/common.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dat/utils/common.js b/src/dat/utils/common.js index 1b3ec0b..0a6e655 100644 --- a/src/dat/utils/common.js +++ b/src/dat/utils/common.js @@ -65,7 +65,8 @@ const Common = { 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); } else if (obj.length === obj.length + 0) { // Is number but not NaN let key; @@ -128,8 +129,10 @@ const Common = { return isNaN(obj); }, - isArray: Array.isArray || function(obj) { - return obj.constructor === Array; + //isArray: Array.isArray || function(obj) { + isArray: function(obj) { + //return obj.constructor === Array; + return obj && obj.length >= 0 && typeof obj === 'object'; }, isObject: function(obj) {