使用异步迭代器消费可读流


(async function() {
  for await (const chunk of readable) {
    console.log(chunk);
  }
})();

异步迭代器在流上注册一个永久的错误句柄,以防止任何未处理的销毁后错误。

(async function() {
  for await (const chunk of readable) {
    console.log(chunk);
  }
})();

Async iterators register a permanent error handler on the stream to prevent any unhandled post-destroy errors.