Package Exports
- trie-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (trie-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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 delimiter
const trie = new Trie();
// trie with some initial values
const trie = new Trie(['abc', 'def']);
// trie with some initial values that are also iterable
const trie = new Trie([['a', 'b', 'c'], ['a', 'b', 'd']]);
// trie with custom object implementing iterator
const obj1 = {
[Symbol.iterator]: function*() {
yield 'a';
yield 'b';
yield 'd'
}
}
const trie = new Trie([obj1]);
Adding, removing, and testing for values
const trie = new Trie();
// Adding is chainable
trie.add('abc')
.add('def')
.add('ghi');
// Removing is chainable
trie.remove('abc')
.remove('def');
trie.lookup('abc') // false
trie.lookup('ghi') // true
Checking for prefixes
const trie = new Trie(['abc', 'def']);
trie.isPrefix('ab') // true
trie.isPrefix('abc') // false