From bf8470e1311bce02de4687dd9d1488a6484ccf6a Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 17 Sep 2017 23:59:30 +0900 Subject: fix for lint --- src/background/histories.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/background/histories.js b/src/background/histories.js index b369dd2..c94809b 100644 --- a/src/background/histories.js +++ b/src/background/histories.js @@ -10,7 +10,7 @@ const filterHttp = (items) => { const filterEmptyTitle = (items) => { return items.filter(item => item[0].title && item[0].title !== ''); -} +}; const reduceByPathname = (items, min) => { let hash = {}; @@ -29,7 +29,7 @@ const reduceByPathname = (items, min) => { return filtered; }; -const reduceByOrigin= (items, min) => { +const reduceByOrigin = (items, min) => { let hash = {}; for (let item of items) { let origin = item[1].origin; @@ -51,16 +51,17 @@ const getCompletions = (keyword) => { return browser.history.search({ text: keyword, startTime: '1970-01-01' - }).then((items) => { - items = items.map(item => [item, new URL(item.url)]); - items = filterEmptyTitle(items); - items = filterHttp(items); - items = reduceByPathname(items, 10); - items = reduceByOrigin(items, 10); - return items - .sort((x, y) => x[0].visitCount < y[0].visitCount) - .slice(0, 10) - .map(item => item[0]); + }).then((historyItems) => { + return [historyItems.map(item => [item, new URL(item.url)])] + .map(filterEmptyTitle) + .map(filterHttp) + .map(items => reduceByPathname(items, 10)) + .map(items => reduceByOrigin(items, 10)) + .map(items => items + .sort((x, y) => x[0].visitCount < y[0].visitCount) + .slice(0, 10) + .map(item => item[0]) + )[0]; }); }; -- cgit v1.2.3