🤯

Node.js で Readable な Stream を複製する最も正しい方法

に公開

こうです。

import { Readable } from 'node:stream'

export const tee = (r: Readable) => {
  const [r1, r2] = Readable.toWeb(r).tee()
  return [Readable.fromWeb(r1), Readable.fromWeb(r2)] as const
}

Node.js でストリームを扱う最も正しい方法

全部 Web Streams API に変換してください。
必要なものは全てそろっています。

(過言かもしれない)

GitHubで編集を提案

Discussion