diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-06-18 20:52:54 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-18 20:52:54 +0900 |
commit | 897e010f42cbc9968cf1058116b0f8bbe9e9a4fd (patch) | |
tree | 3cba586e52ef703d1b49a85ad15d91aca4cbc65f /src/background/shared/completions/histories.js | |
parent | 7cae7302bd39a7963b765cd3defd05a093c104a6 (diff) | |
parent | b74acf6f6aef4e4241ba62c72ed8ddb21adc751d (diff) |
Merge pull request #417 from ueokande/async-function
Use await/async on e2e test
Diffstat (limited to 'src/background/shared/completions/histories.js')
-rw-r--r-- | src/background/shared/completions/histories.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/background/shared/completions/histories.js b/src/background/shared/completions/histories.js index a7d3d47..2d35401 100644 --- a/src/background/shared/completions/histories.js +++ b/src/background/shared/completions/histories.js @@ -61,23 +61,22 @@ const reduceByOrigin = (items, min) => { return filtered; }; -const getCompletions = (keyword) => { - return browser.history.search({ +const getCompletions = async(keyword) => { + let historyItems = await browser.history.search({ text: keyword, startTime: 0, - }).then((historyItems) => { - return [historyItems.map(item => [item, new URL(item.url)])] - .map(filterEmptyTitle) - .map(filterHttp) - .map(filterClosedPath) - .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]; }); + return [historyItems.map(item => [item, new URL(item.url)])] + .map(filterEmptyTitle) + .map(filterHttp) + .map(filterClosedPath) + .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]; }; export { getCompletions }; |