Author: James Brumond
Version: 0.2.1
Copyright 2011 James Brumond
Dual licensed under MIT and GPL
npm install trie
var trie = require('trie');
var myTrie = new trie.Trie();
// Adding words
myTrie.addWord('hello');
myTrie.addWord('world');
// Removing words
myTrie.removeWord('world');
// Checking for words
myTrie.lookup('hello'); // true
myTrie.lookup('world'); // false
// Testing prefixes
myTrie.isValidPrefix('h'); // true
myTrie.isValidPrefix('he'); // true
myTrie.isValidPrefix('ho'); // false
// Serializing
var jsonBlob = myTrie.dumpJson();
// Unserializing
var otherTrie = new trie.Trie();
otherTrie.loadJson(jsonBlob);
// Shortcut functions
var trie3 = trie.createTrieFromArray([ 'word1', 'word2', 'word3' ])
var trie4 = trie.createTrieFromJson(jsonBlob);