Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

How would I do a for loop that waits until my function has completed for each loop?

$
0
0

My current code is this:

const fs = require('fs');
var file = fs.readFileSync('file.txt').toString().split("\n");

for(i in file) {
    var [thing1, thing2, thing3] = file[i].split(":");
    myfunction(thing1, thing2, thing3);
}

This executes a function for each line in the file with some info from the file. For technical reasons, I can only have the function running once at a time. How can I make the for loop wait for the function to complete before looping again?


Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>