readable.destroy([error])


  • error <Error> 将作为 'error' 事件的负载传递的错误
  • 返回:<this>

销毁流。可选择触发一个 'error' 事件,并触发一个 'close' 事件(除非 emitClose 设置为 false)。在此调用之后,可读流将释放任何内部资源,后续对 push() 的调用将被忽略。

【Destroy the stream. Optionally emit an 'error' event, and emit a 'close' event (unless emitClose is set to false). After this call, the readable stream will release any internal resources and subsequent calls to push() will be ignored.】

一旦调用了 destroy(),任何后续调用都将不再起作用,并且除了 _destroy() 外,不会再触发任何 'error' 错误。

【Once destroy() has been called any further calls will be a no-op and no further errors except from _destroy() may be emitted as 'error'.】

实现者不应重写此方法,而应实现 readable._destroy()

【Implementors should not override this method, but instead implement readable._destroy().】