/trie-dict

Fast and memory efficient dictionary using Trie Structure.

Primary LanguageTypeScriptMIT LicenseMIT

Trie Dictionary

Fast and memory efficient dictionary using Trie Structure.

Install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install trie-dict
import TrieDict from "trie-dict";

const dict = TrieDict({ words: ["Trie", "dictionary"], caseSensitive: fasle });;

The options object

words

- default: `[]`
- type: `string[]`

The initial words to add the Trie.

caseSensitive

- default: `true`
- type: `boolean`

Case sensitive dictionary.

API

dict.add(word: string)

Add new word to the dictionary.

dict.has(word: string): boolean

Check if word exist in the dictionary.

dict.remove(word: string): boolean

Remove the word from the dictionary if it exist.

dict.startsWith(initial: string): boolean

Check if the dictionary has any word that starts with initial.