diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-17 23:59:30 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-17 23:59:30 +0900 |
commit | bf8470e1311bce02de4687dd9d1488a6484ccf6a (patch) | |
tree | ae52d3e66be7ccba8577130d4c0e984020caf529 /src | |
parent | 7ace5e1e1979f15bf835af5672999e72e5d8c46f (diff) |
fix for lint
Diffstat (limited to 'src')
-rw-r--r-- | src/background/histories.js | 25 |
1 files changed, 13 insertions, 12 deletions
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]; }); }; |