How to close a readable stream (before end)?

前端 未结 9 1440
名媛妹妹
名媛妹妹 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:58

    This destroy module is meant to ensure a stream gets destroyed, handling different APIs and Node.js bugs. Right now is one of the best choice.

    NB. From Node 10 you can use the .destroy method without further dependencies.

提交回复
热议问题