We will be sunsetting Advisor during Jan, 2026 and will instead be providing information in Snyk Security DB.

You can begin to take advantage of Snyk Security DB today for a unified, package-centric experience.

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 25 days ago

Package Health Score

75 / 100
Full package analysis

Popular trie-search functions