I know node.js works mostly asynchronous, but what if I want to process a job after the previous job has finished. What I want is, I want to loop in a queue and get next job to process. If the job has processed, I get the next. The problem is, because the process is asynchronous, next job is fetched before the previous job has finished.
jobs.ForEach( async job => {
await process(job);
});
So, how can make it such, that the next iteration is done after process(job) has finished. Ironically, I want to make the for-loop synchronously. I could solve it by using EventEmitter and send an finish-event in the process() implementation, to notify the process is done. But is there a cleaner way to achieve this?