aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/node_streams_consumer.exports.js
blob: dba3f6a938ce00ecb1e95ec0e9883ae1fb48d742 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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,
};