mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 02:29:23 +00:00
feature(binom) Util.findObjByNameInArr -> binom
This commit is contained in:
parent
68114e5ac5
commit
74be4c92d0
1 changed files with 26 additions and 16 deletions
|
|
@ -5,23 +5,33 @@
|
|||
|
||||
function binom(name, array) {
|
||||
var ret;
|
||||
|
||||
if (typeof name !== 'string')
|
||||
throw(Error('name should be string!'));
|
||||
|
||||
if (!Array.isArray(array))
|
||||
throw(Error('array should be array!'));
|
||||
|
||||
array.some(function(item) {
|
||||
var is = item.name === name;
|
||||
|
||||
if (is)
|
||||
ret = item;
|
||||
if (!Array.isArray(array))
|
||||
throw(Error('array should be array!'));
|
||||
|
||||
if (typeof name !== 'string')
|
||||
throw(Error('name should be string!'));
|
||||
|
||||
return is;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
array.some(function(item) {
|
||||
var is = item.name === name,
|
||||
isArray = Array.isArray(item);
|
||||
|
||||
if (is)
|
||||
ret = item;
|
||||
else if (isArray)
|
||||
item.some(function(item) {
|
||||
is = item.name === name;
|
||||
|
||||
if (is)
|
||||
ret = item.data;
|
||||
|
||||
return is;
|
||||
});
|
||||
|
||||
return is;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue