This file contains hidden or 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
// Trie.js - super simple JS implementation | |
// https://en.wikipedia.org/wiki/Trie | |
// ----------------------------------------- | |
// we start with the TrieNode | |
function TrieNode(key) { | |
// the "key" value will be the character in sequence | |
this.key = key; | |
This file contains hidden or 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
/** | |
* Control the parallel execution of async tasks. | |
* This function is useful where you want to send out many http requests, but want to control how many inflight requests are inplay at a time. | |
* | |
* @name parallelly | |
* @function | |
* @param {Function} target - This function will be invoked with a taskId (zero based). taskId can be used to ,say, access an item in the queue. | |
* @param {number} concurrencyLevel - How many parallel invocations of target should happen at any given time | |
* @param {number} queueLength - How many times the target should be invoked in total | |
* @return {Promise} Resolves when target is invoked queueLength times or one of the invocations of the target throw an error. |