gpt4 book ai didi

node.js - NodeJS 流 ReadableState

转载 作者:太空宇宙 更新时间:2023-11-03 22:12:07 25 4
gpt4 key购买 nike

NodeJS 文档提到了流动/非流动模式(在 ReadableState 中)。以下摘录进一步解释了可读流一次可能处于的不同可能状态。 ( 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

如果有任何提供更多解释的引用资料,我将不胜感激。我特别好奇每个州的特征/行为;哪些操作会触发不同状态之间的转换?此外。

  • 如果我没记错的话,在流动模式下:流主动生成数据,而在非流动模式下:流不会生成任何数据,直到 r.read(size)叫做。

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

最佳答案

最好的选择可能是在 github 上搜索“flowing”的源代码/存储库。

Readable streams effectively operate in one of two modes: flowing and paused. When in flowing mode, data is read from the underlying system automatically and provided to an application as quickly as possible using events via the … explicitly to read chunks of data from the stream. All [Readable][] streams begin in paused mode but can be switched to flowing

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

关于node.js - NodeJS 流 ReadableState,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39324135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com