Skip to content

Conversation

shanghungshih
Copy link

Thanks for this useful module!!

In my use case, I have to treat the words with case-sensitive, and I realized the trie would convert the word to lowercase no matter what. So I added a parameter called caseSensitive with default value false to fit your original design.

I publish a temporary npm module called trie-prefix-tree-v1.6. Try the example below!

const trie = require('trie-prefix-tree');
const trieWithCaseSensitive = require('trie-prefix-tree-v1.6');

const words = ['abc DEF', 'ABC DEF'];
const input = trie(words);
const inputWithCaseSensitive = trieWithCaseSensitive(words, true);

console.log(`getPrefix of 'a' from input: ${input.getPrefix('a')}`);
console.log(`getPrefix of 'a' from inputWithCaseSensitive: ${inputWithCaseSensitive.getPrefix('a')}`);
/*
getPrefix of 'a' from input: abc def
getPrefix of 'a' from inputWithCaseSensitive: abc DEF
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant