I am trying to read from csv and i am pausing the stream as i need to do do some async task using await. However the done event is called before the all the row has been processed. as I understand even when paused that doesn't stop the done even fron being called. Is there any workaroung to this?
let res = csv({
delimiter: '|',
// noheader: true,
output: "csv",
nullObject: true
})
.fromStream(fs.createReadStream(`./dbscvs/new_${table.name}.csv`))
.on('data', async (data) => {
res.pause()
await new Promise(resolve=>{
setTimeout(resolve,5000)
})
res.resume()
})
.on('done', async e => {
console.log('done')
})
.on('error', (err) => {
console.log(err)
})