- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在阅读文档并且有这个描述,但我不明白它的意思。
All Readable stream implementations must provide a _read method to fetch data from the underlying resource.
This method is prefixed with an underscore because it is internal to the class that defines it, and should not be called directly by user programs. However, you are expected to override this method in your own extension classes.
When data is available, put it into the read queue by calling readable.push(chunk). If push returns false, then you should stop reading. When _read is called again, you should start pushing more data.
底层资源是什么?你什么时候会真正指定一个 _read 函数,这意味着它有什么作用?
最佳答案
_read()
函数用于通知 Readable 流尚未达到 highWaterMark
并且该流可以随意从底层读取更多数据资源。传递给 _read()
的参数是建议从底层资源读取的字节数(或者在 objectMode
情况下的项目数)。
文档中提到的基础资源是指任何数据源。它可以是任何东西,包括另一个可读流,也可以是您动态生成的数据(例如,提供随机二进制数据的可读流)。
关于node.js - 可读流的_read函数在nodejs中有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25449860/
这里的代码块运行良好,直到调用 _read 函数,之后它无缘无故地更改文件句柄变量“fh”的值。 std::string& xLogFile; std::string& xBuffer
以下2个下标有什么区别? subscript(position: Int) { get { ... } } subscript(position: Int) { _read { ...
本题是如何真正实现一个可读流的read方法。 我有一个可读流的实现: import {Readable} from "stream"; this.readableStream = new Readab
我开始在 Atmel Studio 中收到以下链接器错误: c:/program files (x86)/atmel/studio/7.0/toolchain/arm/arm-gnu-toolchai
我了解如何在 Node 的新 Streams2 库中使用可写流,但我不了解如何使用可读流。 例如,围绕 dgram 模块的流包装器: var dgram = require('dgram'); v
我创建自己的阅读流。但我想知道_read()什么时候被调用?如果我不添加on('data')监听器,_read()就不会被调用,为什么? var data = [{"id":0,"name":"obj
我在 win32 下编译 mpg123 库。它不希望它链接到 MSVCR90.DLL 我改变了:C/C++ -> “忽略所有默认库”为 YES 添加“附加依赖项”==> libcmt.lib 《C/C
在 Node.js 中,我有一个可读流: var rs = new (require('stream').Readable);
我正在尝试找出 Node 中的流并尝试 the stream handbook 中的一些示例 我正在尝试 _read可读流的方法。它说,它接受一个参数,该参数是消费者想要读取的字节数。 我有两个问题。
我正在将一个简单的 socket 客户端程序从 Linux 迁移到 Windows (VS2012)。该程序使用常规的close、read 和write 函数。 在 VS2012 中编译时,我收到以下
我是一名优秀的程序员,十分优秀!