7f277d8f7080d5955725a36859257977374ec8a7d4b2c471db7b0b1b355424e292cfdaec153ca094dd30f5e1fe128499b8daea54c8d87d8cdb57bd2ed38a7a 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * The utility consumer functions provide common options for consuming
  3. * streams.
  4. * @since v16.7.0
  5. */
  6. declare module "stream/consumers" {
  7. import { Blob as NodeBlob } from "node:buffer";
  8. import { ReadableStream as WebReadableStream } from "node:stream/web";
  9. /**
  10. * @since v16.7.0
  11. * @returns Fulfills with an `ArrayBuffer` containing the full contents of the stream.
  12. */
  13. function arrayBuffer(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<ArrayBuffer>;
  14. /**
  15. * @since v16.7.0
  16. * @returns Fulfills with a `Blob` containing the full contents of the stream.
  17. */
  18. function blob(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<NodeBlob>;
  19. /**
  20. * @since v16.7.0
  21. * @returns Fulfills with a `Buffer` containing the full contents of the stream.
  22. */
  23. function buffer(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<Buffer>;
  24. /**
  25. * @since v16.7.0
  26. * @returns Fulfills with the contents of the stream parsed as a
  27. * UTF-8 encoded string that is then passed through `JSON.parse()`.
  28. */
  29. function json(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<unknown>;
  30. /**
  31. * @since v16.7.0
  32. * @returns Fulfills with the contents of the stream parsed as a UTF-8 encoded string.
  33. */
  34. function text(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<string>;
  35. }
  36. declare module "node:stream/consumers" {
  37. export * from "stream/consumers";
  38. }