Open KamasamaK opened 5 years ago
This issue has now been resolved in 1.5.1. If you have any questions, please get in touch.
@lyndseybrowning Thanks! It looks like the my second example does not produce an error anymore and gets the expected result. However, the first example still erroneously shows that test
was added to the trie.
I've found that using $
is problematic in a few other situations too:
var triePrefixTree = require("trie-prefix-tree");
var allFunctionNames = triePrefixTree([]);
allFunctionNames.addWord("$test");
allFunctionNames.addWord("$");
console.log(allFunctionNames.getPrefix("te"));
Produces an error TypeError: Cannot create property '$' on number '1'
.
var triePrefixTree = require("trie-prefix-tree");
var allFunctionNames = triePrefixTree([]);
allFunctionNames.addWord("$test");
allFunctionNames.addWord("$clone");
console.log(allFunctionNames.getPrefix("$te"));
Returns an empty array.
Should I not use this package if my words contain $
or are these things that can be addressed?
The issue is that the Trie uses the $ key to indicate the end of a word. I'd rather not change that.
I think my previous fix can be used to resolve the remaining issues. I'll take a look and get back to you.
If I have something like
I get
["test", "test$clone"]
even though I never addedtest
.Worse, if I do add
test
as belowit produces an error:
TypeError: Cannot create property 'c' on number '1'