I've been struggling for 6 days just to find a solution which can give me buffered output of a given large file. The file can be text, binary, etc.
The code below gives a buffered output of only small files. Providing large files makes it crash.
var fs = require('fs')
var stream = fs.createReadStream('big-file')
stream.on('data', function (data) {
console.log(data)
})
I also tried using 'byline' library
var fs = require('fs')
var byline = require('byline')
var stream = fs.createReadStream('big-file')
var buffered_stream = byline.createStream(stream, { keepEmptyLines : true )
buffered_stream.on('data', function (data) {
console.log(data)
})
It gives the buffered output of each line but the bytes are corrupted because extended ASCII characters are multi-bye characters.
If someone can, please help me. Thanks in advance.