aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--types/bun/bun.d.ts34
1 files changed, 32 insertions, 2 deletions
diff --git a/types/bun/bun.d.ts b/types/bun/bun.d.ts
index 3715d16b0..dcecd3c19 100644
--- a/types/bun/bun.d.ts
+++ b/types/bun/bun.d.ts
@@ -219,18 +219,48 @@ declare module "bun" {
*
* Concatenate the chunks into a single {@link ArrayBuffer}.
*
- * Each chunk must be a TypedArray or an ArrayBuffer.
+ * Each chunk must be a TypedArray or an ArrayBuffer. If you need to support chunks of different types, consider {@link readableStreamToBlob}.
*
* @param stream The stream to consume.
* @returns A promise that resolves with the concatenated chunks or the concatenated chunks as an `ArrayBuffer`.
*/
- export function readableStreamToArrayBuffer<T>(
+ export function readableStreamToArrayBuffer(
stream: ReadableStream
): Promise<ArrayBuffer> | ArrayBuffer;
/**
* Consume all data from a {@link ReadableStream} until it closes or errors.
*
+ * Concatenate the chunks into a single {@link Blob}.
+ *
+ * @param stream The stream to consume.
+ * @returns A promise that resolves with the concatenated chunks as a {@link Blob}.
+ */
+ export function readableStreamToBlob(stream: ReadableStream): Promise<Blob>;
+
+ /**
+ * Consume all data from a {@link ReadableStream} until it closes or errors.
+ *
+ * Concatenate the chunks into a single string. Chunks must be a TypedArray or an ArrayBuffer. If you need to support chunks of different types, consider {@link readableStreamToBlob}.
+ *
+ * @param stream The stream to consume.
+ * @returns A promise that resolves with the concatenated chunks as a {@link String}.
+ */
+ export function readableStreamToText(stream: ReadableStream): Promise<string>;
+
+ /**
+ * Consume all data from a {@link ReadableStream} until it closes or errors.
+ *
+ * Concatenate the chunks into a single string and parse as JSON. Chunks must be a TypedArray or an ArrayBuffer. If you need to support chunks of different types, consider {@link readableStreamToBlob}.
+ *
+ * @param stream The stream to consume.
+ * @returns A promise that resolves with the concatenated chunks as a {@link String}.
+ */
+ export function readableStreamToJSON(stream: ReadableStream): Promise<any>;
+
+ /**
+ * Consume all data from a {@link ReadableStream} until it closes or errors.
+ *
* @param stream The stream to consume
* @returns A promise that resolves with the chunks as an array
*