Say I have some code that looks like this:
const myObject = {
outerList : [
{
innerList: [
1, 2, 3
]
},
{
innerList: [
2, 4, 6
]
}
]
};
async function asyncTransform(i) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(i+1);
}, Math.random()* 1000);
});
}
async function asyncTransformNestedObject(obj) {
//???
}
asyncTransformNestedObject(myObject).then((result) => {
console.log(result);
});
And I want to transform the object to this:
{
outerList : [
{
innerList: [
2, 3, 4
]
},
{
innerList: [
3, 5, 7
]
}
]
};
What would the best way to do this be - ideally in a way where the async functions run simultaneously.