readable.push('')
不推荐使用 readable.push('')
。
将零字节字符串、Buffer
或 Uint8Array
推送到非对象模式的流有一个有趣的副作用。
因为是对 readable.push()
的调用,所以调用会结束读取过程。
然而,因为参数是空字符串,没有数据被添加到可读缓冲区,所以用户没有任何东西可以消费。
Use of readable.push('')
is not recommended.
Pushing a zero-byte string, Buffer
, or Uint8Array
to a stream that is not in
object mode has an interesting side effect. Because it is a call to
readable.push()
, the call will end the reading process.
However, because the argument is an empty string, no data is added to the
readable buffer so there is nothing for a user to consume.