Last active
May 24, 2018 21:14
-
-
Save popovkos/ee8b203e0c0ed4d8496cb7bb75ffedab to your computer and use it in GitHub Desktop.
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
async function someFunction() { | |
const myArray = [1, 2, 3]; | |
const connection = mysql.createConnection({ options }); | |
let finalArray = []; | |
myArray.forEach((value) => { // standard forEach | |
finalArray.push(asyncFunction(connection, value)); // pushing promises into an array | |
}); | |
const resolvedfinalArray = await Promise.all(finalArray); // resolving all promises | |
// iterate over some in order to do something like | |
// const iteratedResolvedfinalArray = []; | |
// for(..) { | |
// iteratedResolvedfinalArray[i].soasyncFunctionValueme = resolvedfinalArray[i].asyncFunctionValue; | |
// } | |
// return functionThatUsesResolvedValues(iteratedResolvedfinalArray); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment