From cc8309d04613a1178ecad5cbe4026dde02d18814 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 17 Feb 2015 08:49:27 -0500 Subject: [PATCH] refactor(util) getNamesFromObjArray --- lib/util.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/util.js b/lib/util.js index 1fee41e5..8f8c9b31 100644 --- a/lib/util.js +++ b/lib/util.js @@ -528,16 +528,14 @@ * @pObj */ this.getNamesFromObjArray = function(arr) { - var ret = [], - isArray = Util.type.array(arr); + var ret = []; - if (arr && !isArray) - arr = arr.data; + if (!Array.isArray(arr)) + throw(Error('arr should be array!')); - if (arr) - arr.forEach(function(item) { - ret.push(item.name || item); - }); + arr.forEach(function(item) { + ret.push(item.name); + }); return ret; };