trie-prefix-tree
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -18,2 +18,10 @@ 'use strict'; | ||
/** | ||
* Get the generated raw trie object | ||
*/ | ||
tree: function tree() { | ||
return trie; | ||
}, | ||
/** | ||
* Get a string representation of the trie | ||
@@ -20,0 +28,0 @@ */ |
{ | ||
"name": "trie-prefix-tree", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Create and modify trie prefix structures, extract word lists including anagrams and sub-anagrams", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -86,2 +86,7 @@ # Trie Prefix Tree | ||
```javascript | ||
// retrieve the Trie object instance | ||
myTrie.tree(); | ||
``` | ||
```javascript | ||
// add a new word to the Trie | ||
@@ -118,2 +123,8 @@ myTrie.addWord('lion'); | ||
myTrie.getPrefix('c'); // ['cat', 'cats'] | ||
// Pass false as the second parameter to disable | ||
// output being sorted alphabetically | ||
// this is useful when your dictionary is already sorted | ||
// and will therefore save performance | ||
myTrie.getPrefix('c', false); // ['cat', 'cats'] | ||
``` | ||
@@ -125,3 +136,9 @@ | ||
// retrieve a full list of words in the Trie | ||
myTrie.getWords(); // ['cat', 'cats', 'elephant', 'lion', 'tiger']; | ||
// the output array is automatically sorted | ||
myTrie.getWords(); // ['cat', 'cats', 'elephant', 'lion', 'tiger'] | ||
// pass false to disable the output being sorted | ||
// this is useful when your dictionary is already sorted | ||
// and will therefore save performance | ||
myTrie.getWords(false); // ['cat', 'cats', 'elephant', 'tiger', 'lion'] | ||
``` | ||
@@ -131,3 +148,3 @@ | ||
// check if a word exists in the Trie | ||
myTrie.hasword('elephant'); // true | ||
myTrie.hasWord('elephant'); // true | ||
myTrie.hasWord('zoo'); // false | ||
@@ -134,0 +151,0 @@ ``` |
19316
332
168