可读流中的txt.properties属性,该属性用于检查在构造Readable流时使用的highWaterMark的值。
用法:
readable.readableHighWaterMark
返回值:它返回在构造Readable流时使用的highWaterMark的值。
下面的示例说明了Node.js中visible.sensitiveHighWaterMark属性的使用:
范例1:
// Node.js program to demonstrate the
// readable.readableHighWaterMark Property
// Include fs module
const fs = require("fs");
// Constructing readable stream
const readable = fs.createReadStream("input.txt");
// Instructions for reading data
readable.on('readable', () => {
let chunk;
// Using while loop and calling
// read method with parameter
while (null !== (chunk = readable.read())) {
// Displaying the chunk
console.log(`read:${chunk}`);
}
});
// Calling readable.readableHighWaterMark
// Property
readable.readableHighWaterMark;
输出:
65536 read:GeeksforGeeks
范例2:
// Node.js program to demonstrate the
// readable.readableHighWaterMark Property
// Accessing stream module
const stream = require('stream');
// Creating a stream and setting the value
// of the highWaterMark
const readable = new stream.Readable({
highWaterMark:1234
});
// Calling readable.readableHighWaterMark
// Property
readable.readableHighWaterMark;
输出:
1234
参考: https://nodejs.org/api/stream.html#stream_readable_readablehighwatermark。
相关用法
- node.js Stream writable.writableHighWaterMark用法及代码示例
- node.js Stream readable.readableObjectMode用法及代码示例
- node.js Stream readable.readableLength用法及代码示例
- node.js Stream writable.writableFinished用法及代码示例
- node.js Stream writable.writableObjectMode用法及代码示例
- node.js Stream writable.writableLength用法及代码示例
- node.js Stream writable.writableEnded用法及代码示例
- node.js Stream writable.destroyed用法及代码示例
- node.js Stream readable.destroyed用法及代码示例
- node.js Stream readable.readableEncoding用法及代码示例
- node.js Stream readable.readableEnded用法及代码示例
- node.js Stream writable.writableCorked用法及代码示例
- node.js Stream readable.readableFlowing用法及代码示例
- node.js Stream writable.writable用法及代码示例
注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Node.js | Stream readable.readableHighWaterMark Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。