trie-js
Javascript implementation of a Trie with customizable delimiters designed for use with the node environment.
Installing
npm install trie-js
Creating a trie
// empty Trie with default delimiterconst trie = ; // trie with some initial valuesconst trie = 'abc' 'def'; // trie with some initial values that are also iterableconst trie = 'a' 'b' 'c' 'a' 'b' 'd'; // trie with custom object implementing iteratorconst obj1 = Symboliterator: { 'a'; 'b'; 'd' } const trie = obj1;
Adding, removing, and testing for values
const trie = ; // Adding is chainabletrie ; // Removing is chainabletrie ; trie // falsetrie // true
Checking for prefixes
const trie = 'abc' 'def'; trie // truetrie // false