Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'search': async (params) => {
const limit = parseInt(params.limit, 10);
const query = params.query;
const start = performance.now();
let items = trie.get(query, TrieSearch.UNION_REDUCER) || [];
const total = items.length;
if (limit) items = items.slice(0, limit);
const time = (performance.now() - start).toFixed(1);
console.log('Returned %s results in %s ms.', items.length, time);
return {
items: items,
total: total,
};
},
function search(query, maxResults) {
let results = trie.get(query, TrieSearch.UNION_REDUCER) || [];
const count = results.length;
if (maxResults) {
results = results.slice(0, maxResults);
}
postMessage({
type: 'results',
payload: {
results: results,
count: count,
}
});
}