Last active
August 20, 2018 03:56
-
-
Save greyscaled/eabf9cf6e00b09f77c5a22ba2b88a77c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Trie { | |
constructor () { | |
this.root = new Node() | |
} | |
put (key = '', val = null) { | |
this.root = recursiveInsert(this.root, key, val, 0) | |
} | |
// ... | |
} | |
const recursiveInsert = (node, key, val, d) => { | |
// private helper method to insert a key/val through | |
// a recursive walk | |
} | |
if (process.env.NODE_ENV === 'test') { | |
// only expose private methods for testing | |
module.exports = { | |
Trie, | |
recursiveInsert | |
} | |
else { | |
// in production, development - only Trie is exposed | |
module.exports = Trie | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment