The
readable[Symbol.asyncIterator]() method in a Readable Stream is utilized to fully consume the stream.
Syntax:
readable[Symbol.asyncIterator]()
Parameters: This method does not accept any parameters.
Return Value: It returns
asyncIterator to fully consume the stream.
Below examples illustrate the use of
readable[Symbol.asyncIterator]() method in Node.js:
Example 1:
Output:
Promise { <Pending> }
GeeksforGeeks
Example 2:
Output:
program ends!!!
GfG
CS-Portal
Reference: https://nodejs.org/api/stream.html#stream_readable_symbol_asynciterator.