'finish' 与 'end' 事件


'finish' 事件来自 stream.Writable 类,'end' 事件来自 stream.Readable 类。 当调用了 stream.end() 并且 stream._transform() 处理完全部数据块之后,触发 'finish' 事件。 当调用了 transform._flush() 中的回调函数并且所有数据已经输出之后,触发 'end' 事件。

The 'finish' and 'end' events are from the stream.Writable and stream.Readable classes, respectively. The 'finish' event is emitted after stream.end() is called and all chunks have been processed by stream._transform(). The 'end' event is emitted after all data has been output, which occurs after the callback in transform._flush() has been called.