The
readable.destroyed property is an inbuilt application programming interface of Stream module which is used to check the readable.destroy() function is being called or not.
Syntax:
readable.destroyed
Return Value: It returns true if readable.destroy() method is being called otherwise returns false.
Below examples illustrate the use of
readable.destroyed property in Node.js:
Example 1:
Output:
Stream destroyed
true
error
Example 2:
Output:
Program completed!!
false
read: hello
So, here readable.destroy() method is not called before readable.destroyed property so it returns false.
Reference: https://nodejs.org/api/stream.html#stream_readable_destroyed