writable.destroy([error])


销毁流,并触发 'error' 事件且传入 error 参数。 调用该方法后,可写流就结束了,之后再调用 write()end() 都会导致 ERR_STREAM_DESTROYED 错误。 实现流时不应该重写这个方法,而是重写 writable._destroy()

Destroy the stream, and emit the passed 'error' and a 'close' event. After this call, the writable stream has ended and subsequent calls to write() or end() will result in an ERR_STREAM_DESTROYED error. Implementors should not override this method, but instead implement writable._destroy().