my code looks something like this
var fs = require('fs');
var prom = require('prom');
fs.readFile('./bat.txt', function(err, data) {
bar=JSON.parse(data);
for(var x=0;x<Object.keys(bar).length;x++){
prom.f(bar[x]).then(res => {console.log({bar[x]: res});
})}}
bar[x] is out of date by the time the callback is called and I didn't write prom.f() and can't change it. I have no idea how to solve this please help!!!