How to close a readable stream (before end)?

前端 未结 9 1428
名媛妹妹
名媛妹妹 2020-11-29 03:16

How to close a readable stream in Node.js?

var input = fs.createReadStream(\'lines.txt\');

input.on(\'data\', function(data) {
   // after closing the strea         


        
9条回答
  •  野性不改
    2020-11-29 03:49

    Today, in Node 10

    readableStream.destroy()

    is the official way to close a readable stream

    see https://nodejs.org/api/stream.html#stream_readable_destroy_error

提交回复
热议问题