Creates a new CompressedTrie
instance.
Optional
initialWords: string[] | readonly string[]Optional array of [word, value]
pairs to initialize the compressed-trie with.
Makes the CompressedTrie
iterable.
Words are yielded in their insertion order by default.
Optional
reversed: boolean = falseOptional boolean
to reverse iteration order.
An iterator for the compressed-trie's entries.
Adds a word to the compressed-trie. If the word already exists, it will not create duplicates and the original insertion order is preserved.
The word to add.
Removes a word from the compressed-trie.
The word to remove.
true
if the word was found and removed, false
if not found.
Returns an iterator of all words in the compressed-trie.
Words are yielded in their insertion order by default.
Optional
reversed: boolean = falseOptional boolean
to reverse iteration order.
An iterator of the compressed-trie's entries.
Finds all words that start with the given prefix.
The prefix to search for.
An array of matching words.
Executes a callback function for each entry in the compressed-trie.
The word of the current entry.
The compressed-trie instance being traversed.
Optional
thisArg: anyChecks if a word exists in the compressed-trie.
The word to check.
true
if the exact word exists, false
otherwise.
A memory-optimized trie (radix tree) implementation that extends
AbstractTrie
.Example