更新时间:2021-11-16 09:24:18
调用input.close()
.它不在文档中,但是
Invoke input.close()
. It's not in the docs, but
https://github.com/joyent/node/blob/cfcb1de130867197cbc9c6012b7d84 /lib/fs.js#L1597-L1620
显然可以完成工作:)实际上它执行的操作与您的isEnded
类似.
clearly does the job :) It actually does something similar to your isEnded
.
编辑2015年4月19日:基于以下评论,并进行澄清和更新:
EDIT 2015-Apr-19 Based on comments below, and to clarify and update:
lib/fs.js
,但仍可以在> 1.5年后使用.destroy()
的意见.fs
ReadStreams
,而不适用于通用Readable
lib/fs.js
it still works >1.5yrs later.destroy()
being preferable.fs
ReadStreams
's, not on a generic Readable
对于通用解决方案:至少从我对文档的理解以及对_stream_readable.js
的快速了解来看,它似乎并不存在.
As for a generic solution: it doesn't appear as if there is one, at least from my understanding of the documentation and from a quick look at _stream_readable.js
.
我的建议是将您的可读流置于已暂停模式,至少防止上游数据源中的进一步处理.如 the文档
My proposal would be put your readable stream in paused mode, at least preventing further processing in your upstream data source. Don't forget to unpipe()
and remove all data
event listeners so that pause()
actually pauses, as mentioned in the docs