
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
trie-autocomplete
Advanced tools
A fast and lightweight autocomplete library using a trie data structure.
This library uses a prefix trie data structure to efficiently generate autocomplete suggestions.
const AutoComplete = require('trie-autocomplete');
const trie = new AutoComplete();
Adds a word to the trie. Words inside the trie can be return as suggestions later.
Example:
// Create a new AutoComplete trie
const trie = new AutoComplete();
// Add "hello" to the trie
trie.add('hello');
// AutoComplete trie now contains "hello"
Tests if the AutoComplete trie contains a given word. REturns a boolean.
Example:
// Create an empty AutoComplete trie
const trie = new AutoComplete();
// Trie shouldn't contain anything yet. This returns false
let containsHello = trie.contains('hello')
trie.add('hello');
// This returns true now
containsHello = trie.contains('hello')
Takes a word prefix and returns an array of all words in the tree which begin with the prefix.
Rather than searching the whole tree, .suggest()
will search the subtree
rooted at the last character in the prefix, eliminating most of the nodes
from the search.
Example:
// Create empty AutoComplete trie
const trie = new AutoComplete();
// Add some words
trie.add('hello');
trie.add('helium');
trie.add('help');
trie.add('happy');
trie.add('cat');
trie.add('catastrophe');
// Get suggestions for the prefix 'he'.
const suggestions = trie.suggest('he'); // ['hello', 'helium', 'help']
FAQs
A fast and lightweight autocomplete library using a trie data structure.
We found that trie-autocomplete demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.