make Ox.compact more compact and flatten Ox.flatten

This commit is contained in:
rolux 2012-07-13 15:51:49 +02:00
parent 518a032325
commit ff1e6d4833

View file

@ -399,7 +399,7 @@ Ox.compact <f> Removes `null` or `undefined` values from an array
@*/ @*/
Ox.compact = function(array) { Ox.compact = function(array) {
return array.filter(function(value) { 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 = []; var ret = [];
array.forEach(function(value) { array.forEach(function(value) {
if (Ox.isArray(value)) { if (Ox.isArray(value)) {
Ox.flatten(value).forEach(function(value) { ret = ret.concat(Ox.flatten(value));
ret.push(value);
});
} else { } else {
ret.push(value); ret.push(value);
} }