From b6f5b45279010d98f85da815eab3a5b707e3d4f0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Jun 2014 04:50:23 -0400 Subject: [PATCH] feature(util) findObjByNameInArr: find array in array first --- json/modules.json | 6 +++--- lib/util.js | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/json/modules.json b/json/modules.json index c4faf05b..f739aaa0 100644 --- a/json/modules.json +++ b/json/modules.json @@ -8,7 +8,7 @@ "contact", "socket", "terminal", - "console", { + "console", [{ "name": "storage", "data": [{ "name": "DropBox", @@ -48,5 +48,5 @@ } } ] - } -] \ No newline at end of file + }] +] diff --git a/lib/util.js b/lib/util.js index 7b5059fb..c64401d3 100644 --- a/lib/util.js +++ b/lib/util.js @@ -886,12 +886,18 @@ if (isArray) { array.some(function(item) { - var is = item.name === name; + var is, + isArray = Util.isArray(item); - if (is) - ret = item.data; + if (isArray) + item.some(function(item) { + is = item.name === name; + + if (is) + ret = item.data; + }); - return is; + return is; }); }