我当前的代码是这样:
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);
}
这将使用文件中的一些信息为文件中的每一行执行一个功能。由于技术原因,我一次只能运行一次该功能。如何让for循环在再次循环之前等待函数完成?
如果我的功能已同步,则您的代码已在工作中
其他方式:
await myfunction(thing1, thing2, thing3);
请确保在代码块之前添加async