Skip to content

Add caseSensitive parameter #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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