Node.js | Stream readable.isPaused() Method

The readable.isPaused() method is an inbuilt application programming interface of Stream module which is used to check the current operating state of the Readable streams.

Syntax:

readable.isPaused()

Parameters: This method does not accept any parameters.

Return Value: It returns true if the Readable state is paused otherwise returns false.

Below examples illustrate the use of readable.isPaused() method in Node.js:



Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Node.js program to demonstrate the     
// readable.isPaused() method  
  
// Include stream module
const stream = require('stream');
  
// Constructing readable stream
const readable = new stream.Readable();
  
// Calling isPaused method
readable.isPaused();

chevron_right


Output:

false

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Node.js program to demonstrate the     
// readable.isPaused() method  
  
// Include stream module
const stream = require('stream');
  
// Constructing readable stream
const readable = new stream.Readable();
  
// Calling isPaused method
readable.isPaused();
  
// Calling the pause() function
// to pause readable state
readable.pause();
  
// Again calling isPaused to check
// if its paued or not
readable.isPaused();

chevron_right


Output:

true

Reference: https://nodejs.org/api/stream.html#stream_readable_ispaused

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.