aboutsummaryrefslogtreecommitdiff
path: root/src/js/node/stream.consumers.js
blob: 4df51d1bf075d7315d447255d7bf1b72da93f1fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Hardcoded module "node:stream/consumers" / "readable-stream/consumer"
const arrayBuffer = Bun.readableStreamToArrayBuffer;
const text = Bun.readableStreamToText;
const json = stream => Bun.readableStreamToText(stream).then(JSON.parse);

const buffer = async readableStream => {
  return new Buffer(await arrayBuffer(readableStream));
};

const blob = Bun.readableStreamToBlob;

export default {
  arrayBuffer,
  text,
  json,
  buffer,
  blob,
};