How to use the trie-search.UNION_REDUCER function in trie-search

To help you get started, we’ve selected a few trie-search examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mmontag / chip-player-js / public / index.js View on Github external
'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,
    };
  },
github mmontag / chip-player-js / src / SearchWorker.js View on Github external
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,
    }
  });
}

trie-search

A trie implementation that maps keys to objects for rapid retrieval by phrases. Most common use will be for typeahead searches.

MIT
Latest version published 8 months ago

Package Health Score

64 / 100
Full package analysis

Popular trie-search functions