1.2.32 • Published 5 years ago

@clarketm/supertrie v1.2.32

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

Trie

NPM release

Trie with superpowers! 💪

Individual Module Installation

Yarn

$ yarn add @clarketm/supertrie

Npm

$ npm install @clarketm/supertrie --save

API

constructor(iterable: Iterable<string>)

Construct a Trie

root: TrieNode

Get the root of the trie

insert(word: string)

Insert a string into the trie

NameTypeAttributeDescription
wordstringstring to insert

remove(word: string)

Remove a string from the trie

NameTypeAttributeDescription
wordstringstring to remove

search(query: string): Match

Search for a node in the trie matching the query

NameTypeAttributeDescription
querystringstring query to search for

includes(word: string): boolean

Check if the trie includes a word

NameTypeAttributeDescription
wordstringfull word to search for

contains(word: string): boolean

Alias to includes(word)

Check if the trie contains a word

NameTypeAttributeDescription
wordstringfull word to search for

startsWith(prefix: string): boolean

Check if the trie contains a prefix

NameTypeAttributeDescription
prefixstringprefix (i.e. partial word) to search for

TrieNode

TrieNode

constructor(char: character)

Construct a TrieNode

count: number

Get children count of the node

char: character

Get character value of node

isCompleteWord: boolean

Checks if node is a complete word

has(char: character): boolean

Check if node has a specific character as a child

NameTypeAttributeDescription
charcharactercharacter to check

get(char: character): TrieNode

Get child node with specific character value

NameTypeAttributeDescription
charcharactercharacter to get

set(char: character, node: TrieNode)

Set child node with specific character value

NameTypeAttributeDescription
charcharactercharacter to set
nodeTrieNodenode to assign to character

delete(char: character)

Delete child node with specific character value

NameTypeAttributeDescription
charcharactercharacter to delete
1.2.32

5 years ago

1.2.31

6 years ago

1.2.25

6 years ago

1.2.20

6 years ago

1.2.18

6 years ago

1.2.17

6 years ago

1.2.16

6 years ago

1.2.15

6 years ago

1.2.14

6 years ago

1.2.13

6 years ago

1.2.11

6 years ago

1.2.9

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago