The
'readable' Event in a Readable Stream is emitted when the data is available so that it can be read from the stream or it can be emitted by adding a listener for the 'readable' event which will cause data to be read into an internal buffer.
Syntax:
Event: 'readable'
Below examples illustrate the use of
readable event in Node.js:
Example 1:
Output:
Done...
read: GeeksforGeeks
Example 2:
Output:
Done.
readable: GeeksforGeeks
readable: null
Stream ended
Here, end event is emitted so null is returned.
Reference: https://nodejs.org/api/stream.html#stream_event_readable