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
/** | |
* This snippet assumes large input and large output and that all the input contains numbers in the form of string | |
*/ | |
package main | |
import ( | |
"bufio" | |
"io/ioutil" | |
"os" |
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
function* generatorFn(arr = [], asyncFn) { | |
for(let item of arr) { | |
// Alter this function according to your needs. | |
// Also note that the below code would remain the same even in case of async-await functions | |
yield asyncFn(item) | |
} | |
} | |
async function execSequentially(arr, asyncFn) { | |
let gen = generatorFn(arr, asyncFn) |