I want to read large text file and check number at each line in my redis database so basically i have to async/await my redis command below given is my code i tried to use event-stream
function readFile()
{
return new Promise(function (resolve, reject) {
let totalLines = 0;
var s=fs.createReadStream("/var/www/uploads/"+filename);
s.pipe(es.split())
.pipe(
es.map(function (line, cb) {
cb(customFunction(line))
})
.on("error", function (err) {
reject(err);
})
.on("end", function () {
resolve("ok");
})
);
})
}
function customFuntion(line){
async()=>{
var res=await redisClient.get(line);
console.log(res)
}();
}
the issue is code doesn't wait for redis result instead it resolves the promise of readFile function before redis result is displayed