Use async/await on background
This commit is contained in:
parent
88238005ab
commit
48e4bccf0d
12 changed files with 273 additions and 316 deletions
src/background/shared/completions
|
@ -1,15 +1,14 @@
|
|||
const getCompletions = (keywords) => {
|
||||
return browser.bookmarks.search({ query: keywords }).then((items) => {
|
||||
return items.filter((item) => {
|
||||
let url = undefined;
|
||||
try {
|
||||
url = new URL(item.url);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return item.type === 'bookmark' && url.protocol !== 'place:';
|
||||
}).slice(0, 10);
|
||||
});
|
||||
const getCompletions = async(keywords) => {
|
||||
let items = await browser.bookmarks.search({ query: keywords });
|
||||
return items.filter((item) => {
|
||||
let url = undefined;
|
||||
try {
|
||||
url = new URL(item.url);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return item.type === 'bookmark' && url.protocol !== 'place:';
|
||||
}).slice(0, 10);
|
||||
};
|
||||
|
||||
export { getCompletions };
|
||||
|
|
Reference in a new issue