readable.push('')
不推荐使用 readable.push('')
。
¥Use of readable.push('')
is not recommended.
将零字节字符串、Buffer
或 Uint8Array
推送到非对象模式的流会产生有趣的副作用。因为是对 readable.push()
的调用,调用会结束读取过程。然而,因为参数是一个空字符串,所以没有数据被添加到可读缓冲区,所以用户没有任何东西可以使用。
¥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.