节点流:如果可读流已被耗尽(结束已发出),它如何发出另一个可读事件
Node streams: How can a readable stream emit another readable event if it has been drained (end was emitted)
节点文档说(关于可读流的 readable
事件):
Once the internal buffer is drained, a readable event will fire again when more data is available.
但是,它还说:
Event: 'end'
This event fires when there will be no more data to read.
Note that the end event will not fire unless the data is completely
consumed. This can be done by switching into flowing mode, or by
calling read() repeatedly until you get to the end.
所以我的问题是,如果缓冲区被耗尽,它不会发出 end
事件来阻止 readable
事件再次被触发吗?
不,end
不会在缓冲区耗尽时发生。 end
仅当基础资源声明不再推送任何数据时才会发生。
节点文档说(关于可读流的 readable
事件):
Once the internal buffer is drained, a readable event will fire again when more data is available.
但是,它还说:
Event: 'end'
This event fires when there will be no more data to read.
Note that the end event will not fire unless the data is completely consumed. This can be done by switching into flowing mode, or by calling read() repeatedly until you get to the end.
所以我的问题是,如果缓冲区被耗尽,它不会发出 end
事件来阻止 readable
事件再次被触发吗?
不,end
不会在缓冲区耗尽时发生。 end
仅当基础资源声明不再推送任何数据时才会发生。