Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tlhunter/take-home-test-node-trie

Teaching a friend how to implement Tries in JS
https://github.com/tlhunter/take-home-test-node-trie

Last synced: about 1 month ago
JSON representation

Teaching a friend how to implement Tries in JS

Awesome Lists containing this project

README

        

# Node.js Trie

Note: Project is not available on NPM.

## Usage

```js
const Trie = require('trie.js'); // whereever you save trie.js
const words = new Trie();

words.add('the');
words.add('their');
words.add('there');
words.add('orange');

words.has('the') === true // Contains the word 'the'
words.has('ther') === false // Doesn't contain a word 'ther'
words.count('th') === 3 // Has three words that begin with 'th'
words.count() === 4 // Contains 4 words total
words.has('banana') === false // Does not contain 'banana'
```

## Testing

Execute the following:

```sh
./test.js
```