-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
My understanding of pause() with respect to streaming a csv would be to pause the stream at the current record. This would allow async processing to occur before resuming the stream to get the next record.
What's currently happening is the buffer is fully processed before _paused is taken into account.
var count = 0;
var csvStream = new csv.createStream({
endLine : '\n',
escapeChar : '"',
enclosedChar: '"'
})
var readStream = fs.createReadStream(targetPath)
csvStream.on('error', function(err){
console.log(err)
})
csvStream.on('data', function(data){
count++
console.log('pre pause', count)
csvStream.pause()
//I would normally have async code here with a csvStream.resume() in a callback/promise
})
csvStream.on('end', function(){
console.log("we're done")
//cb()
})
readStream.pipe(csvStream)I would expect the stream to pause at each record, but it goes through until the end of file (or buffer in this case) before actually entering the paused state.
Is the intended behaviour to process the entire file/buffer before allowing pause() to occur?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels