From 6cd18e0eff75d85c2a00fa1e015281b2172410ef Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 15 Nov 2018 00:42:16 +0300 Subject: [PATCH] refactored out manual flattening to .flat(..) Signed-off-by: Alex A. Naanou --- ui (gen4)/features/collections.js | 4 ++-- ui (gen4)/features/sort.js | 10 +++------- ui (gen4)/features/tags.js | 3 +-- ui (gen4)/features/ui-widgets.js | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/ui (gen4)/features/collections.js b/ui (gen4)/features/collections.js index b621476c..e7f52751 100755 --- a/ui (gen4)/features/collections.js +++ b/ui (gen4)/features/collections.js @@ -847,7 +847,7 @@ var CollectionActions = actions.Actions({ : [ that.data.getImage(gid) // check base data for image gid... || that.collections[MAIN_COLLECTION_TITLE].data.getImage(gid) ] }) - .reduce(function(a, b){ return a.concat(b) }, []) + .flat() this.ensureCollection(collection) .then((function(c){ @@ -1040,7 +1040,7 @@ var CollectionActions = actions.Actions({ // when adding a ribbon gid expand to images... that.data.ribbons[gid].compact() : [that.data.getImage(gid)] }) - .reduce(function(a, b){ return a.concat(b) }, []) + .flat() // remove from the loaded state... this.collection == collection diff --git a/ui (gen4)/features/sort.js b/ui (gen4)/features/sort.js index d978e17e..cd75265e 100755 --- a/ui (gen4)/features/sort.js +++ b/ui (gen4)/features/sort.js @@ -136,8 +136,7 @@ module.SortActions = actions.Actions({ .filter(function(e){ return e && e.trim() != '' && !/['"]/.test(e) }) : []) - .reduce(function(r, e){ - return r.concat(e instanceof Array ? e : [e]) }, []) } + .flat() } var get = function(name){ // normalize name... name = name @@ -196,9 +195,7 @@ module.SortActions = actions.Actions({ : a instanceof Array ? a : method }) - // merge... - .reduce(function(r, e){ - return r.concat(e instanceof Array ? e : [e]) }, []) }], + .flat() }], // Custom sort methods... // @@ -783,8 +780,7 @@ var SortUIActions = actions.Actions({ function(e){ return expandMethods(e)[0] || [] } : expandMethods) - .reduce(function(r, e){ - return r.concat(e instanceof Array ? e : [e]) }, []) + .flat() .map(function(e){ return indent + e }) : typeof(methods) == typeof('str') ? diff --git a/ui (gen4)/features/tags.js b/ui (gen4)/features/tags.js index 874c7446..3602b0e3 100755 --- a/ui (gen4)/features/tags.js +++ b/ui (gen4)/features/tags.js @@ -223,8 +223,7 @@ var TagUIActions = actions.Actions({ gids = gids .map(function(gid){ return gid == 'marked' ? that.marked : gid }) - .reduce(function(res, cur){ - return res.concat(cur instanceof Array ? cur : [cur]) }, []) + .flat() .unique() // XXX diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 0d5f3c17..422b83a7 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1144,7 +1144,7 @@ var UIIntrospectionActions = actions.Actions({ .html('Handlers: ' + (feature.handlers || [['-']]) .map(function(h){ return h[0] instanceof Array ? h[0] : [h[0]] }) - .reduce(function(a, b){ return a.concat(b) }, []) + .flat() .unique() .map(function(n){ return n == '-' ? n : action2lnk(n) })