Package Exports
- @cshooks/usetrie
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@cshooks/usetrie) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@cshooks/useTrie
A React Hook that returns a Trie, which enables a fast text match with a small memory foot print
Usage
import useTrie from "@cshooks/usetrie";
function App() {
const words = ["abcd", "abce", "ABC", "THE", "their", "there"];
const isCaseSensitive = false;
const trie = useTrie(words, isCaseSensitive);
return <div>...</div>;
}Demo
API
has = (word: string, exactSearch: boolean = true): boolean- what? check if the
wordexists word- a word to search in trieexactSearch- match thewordexactly else does a fuzzy match
- what? check if the
add = (word: string): void- add the
wordto trie
- add the
remove = (word: string): void- remove the
wordfrom trie
- remove the
isEmpty = (root: TrieNode = this.root): boolean- check if the current trie is empty or not.
- optionally check if current trie node is empty or not