summaryrefslogtreecommitdiffstats
path: root/test/node-fetch/utils/read-stream.js
blob: 7d7915329342d8da8e63dd372782c2d5fd0f4608 (plain)
1
2
3
4
5
6
7
8
9
module.exports = async function readStream (stream) {
  const chunks = []

  for await (const chunk of stream) {
    chunks.push(chunk instanceof Buffer ? chunk : Buffer.from(chunk))
  }

  return Buffer.concat(chunks)
}