trie-dict
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i trie-dict

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

9.03 kB

Total Files

6

Last publish

Collaborators

  • ceicc