make Ox.compact more compact and flatten Ox.flatten
This commit is contained in:
parent
518a032325
commit
ff1e6d4833
1 changed files with 2 additions and 4 deletions
|
@ -399,7 +399,7 @@ Ox.compact <f> Removes `null` or `undefined` values from an array
|
|||
@*/
|
||||
Ox.compact = function(array) {
|
||||
return array.filter(function(value) {
|
||||
return !Ox.isNull(value) && !Ox.isUndefined(value);
|
||||
return value != null;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -439,9 +439,7 @@ Ox.flatten = function(array) {
|
|||
var ret = [];
|
||||
array.forEach(function(value) {
|
||||
if (Ox.isArray(value)) {
|
||||
Ox.flatten(value).forEach(function(value) {
|
||||
ret.push(value);
|
||||
});
|
||||
ret = ret.concat(Ox.flatten(value));
|
||||
} else {
|
||||
ret.push(value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue