Open In App

Node.js Stream readable.readableFlowing Property

Last Updated : 12 Oct, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report
The readable.readableFlowing property in a readable stream that utilized to check if the streams are in flowing mode or not. Syntax:
readable.readableFlowing 
Return Value: It returns true if stream is in flowing mode else it returns false. Below examples illustrate the use of readable.readableFlowing property in Node.js: Example 1: JavaScript
// 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;
Output:
true
Example 2: JavaScript
// 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;
Output:
false
Reference: https://nodejs.org/api/stream.html#stream_readable_readableflowing.

Next Article

Similar Reads