'event stream node js large text file read doesn't wait for call back

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)  
}();
}

i am reading a large test file using createReadstream and event stream the issue i am facing is i want to check each number at line in redis but the read file get completed before my console.log in my custom function



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source