可读流中的可读。可读流属性,用于检查流是否处于流模式。
用法:
readable.readableFlowing
返回值:如果流处于流模式,则返回true,否则返回false。
下面的示例说明了Node.js中visible.sensitiveFlowing属性的使用:
范例1:
// Node.js program to demonstrate the
// readable.readableFlowing Property
// Include fs module
var fs = require("fs");
var data = '';
// Create a readable stream
var readerStream = fs.createReadStream('input.txt');
// Handling data event
readerStream.on('data', function(chunk) {
data += chunk;
});
// Calling readableFlowing property
readerStream.readableFlowing;
输出:
true
范例2:
// Node.js program to demonstrate the
// readable.readableFlowing 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.readableFlowing
// Property
readable.readableFlowing;
输出:
false
参考: https://nodejs.org/api/stream.html#stream_readable_readableflowing。
相关用法
- 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 readable.readableHighWaterMark用法及代码示例
- 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 writable.writable用法及代码示例
注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Node.js | Stream readable.readableFlowing Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。