How to close a readable stream in Node.js?
var input = fs.createReadStream(\'lines.txt\'); input.on(\'data\', function(data) { // after closing the strea
This code here will do the trick nicely:
function closeReadStream(stream) { if (!stream) return; if (stream.close) stream.close(); else if (stream.destroy) stream.destroy(); }
writeStream.end() is the go-to way to close a writeStream...