NodeJSstreamReadableState

NodeJS文档提到了stream动/非stream动模式(在ReadableState )。 以下摘录进一步解释了一次可读stream可能处于的不同状态。 ( https://nodejs.org/api/stream.html#stream_three_states )

 Specifically, at any given point in time, every Readable is in one of three possible states: readable._readableState.flowing = null readable._readableState.flowing = false readable._readableState.flowing = true 

我将不胜感激提供更多解释的任何参考。 我特别好奇每个州的特点/行为; 以及哪些行为触发了不同国家之间的转换? 此外。

  • 如果我没有错,在stream动模式下:stream主动生成数据,而在非stream动模式下:直到r.read(size)之前,stream不会生成任何数据。

  • 非stream动模式和暂停模式有什么区别? 当_readableState.flowing == null时, r.isPaused()为false。

最好的办法可能是searchgithub上的source / repo来获得“stream动”。

可读stream有效地以两种模式之一运行:stream动和暂停。 处于stream动模式时,将自动从底层系统读取数据,并尽可能快地使用事件通过…将数据提供给应用程序,以便从数据stream中显式读取数据块。 所有[Readable] []stream开始于暂停模式,但可以切换到stream动

https://github.com/nodejs/node/search?q=flowing&type=Code&utf8=%E2%9C%93