aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/node_streams_consumer.exports.js
blob: d4f775ba9fc050d4fa14e46a10fc29bf4356f6ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const { Bun } = import.meta.primordials;

export const arrayBuffer = Bun.readableStreamToArrayBuffer;
export const text = Bun.readableStreamToText;
export const json = (stream) =>
  Bun.readableStreamToText(stream).then(JSON.parse);

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

export const blob = Bun.readableStreamToBlob;

export default {
  [Symbol.for("CommonJS")]: 0,
  arrayBuffer,
  text,
  json,
  buffer,
  blob,
};