mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-29 02:30:28 +00:00
refactor(util) getNamesFromObjArray
This commit is contained in:
parent
54be194305
commit
cc8309d046
1 changed files with 6 additions and 8 deletions
14
lib/util.js
14
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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue