mckoss / dawg

Directed Acyclic Word Graph
MIT License
41 stars 2 forks source link

Node string fragment conflicts with internal fields #2

Open ahamid opened 6 years ago

ahamid commented 6 years ago

The way Node stores string fragments alongside internal fields is problematic:

new Trie(['child']).optimize()
Uncaught TypeError: this.child is not a function
    at Node.isTerminalString (node.js:51)
    at Node.isTerminal (node.js:56)
    at Trie.collapseChains (trie.js:207)
    at Trie.optimize (trie.js:126)
    at <anonymous>:1:26

"child" is a property holding a Node reference, not the child method from the prototype.

This could possibly be worked around by usage of Symbols to insure internal fields/method never conflict with string fragment properties.