From ff1e6d4833104cd99104af381bd6948a621c12ee Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 13 Jul 2012 15:51:49 +0200 Subject: [PATCH] make Ox.compact more compact and flatten Ox.flatten --- source/Ox/js/Array.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/Ox/js/Array.js b/source/Ox/js/Array.js index ee36619a..da243f4f 100644 --- a/source/Ox/js/Array.js +++ b/source/Ox/js/Array.js @@ -399,7 +399,7 @@ Ox.compact 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); }