I have an array of files that I am adding data to which conceptually works like this:
let filearray = ['file1.txt', 'file2.txt', 'file3.txt'];
newarray = [];
for (let f of filearray) {
newstuff = 'newstuff';
newarray.push([f, newstuff]);
}
console.log(newarray)
// Returns expected array of arrays
However, what I need to do is make newstuff = slow_promise_function(f);
that involves lots of processing. How do I get the value from that promise function into the array?
Ideally I'd like to use the new async
feature in ES2017.
Update:
These answers are helping me understand the problems (and solutions):