Node.js Stream transform.destroy() Method
The transform.destroy() method in a Readable Stream is used to destroy the transform stream, and also emits an ‘error’ event optionally. Moreover, the transform stream releases any internal resources after this call is being made.
transform.destroy( error )
Parameters: This method accepts single parameters error which emits an error event optionally.
Return Value: It emits error event if any error is made in creating stream else it only destroys the transform streams.
Below examples illustrate the use of transform.destroy() method in Node.js:
Here, the transform stream is destroyed so the piping made is also removed.