readable.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Readable } from "stream";
  2. import { Blob } from 'buffer'
  3. export default BodyReadable
  4. declare class BodyReadable extends Readable {
  5. constructor(
  6. resume?: (this: Readable, size: number) => void | null,
  7. abort?: () => void | null,
  8. contentType?: string
  9. )
  10. /** Consumes and returns the body as a string
  11. * https://fetch.spec.whatwg.org/#dom-body-text
  12. */
  13. text(): Promise<string>
  14. /** Consumes and returns the body as a JavaScript Object
  15. * https://fetch.spec.whatwg.org/#dom-body-json
  16. */
  17. json(): Promise<unknown>
  18. /** Consumes and returns the body as a Blob
  19. * https://fetch.spec.whatwg.org/#dom-body-blob
  20. */
  21. blob(): Promise<Blob>
  22. /** Consumes and returns the body as an ArrayBuffer
  23. * https://fetch.spec.whatwg.org/#dom-body-arraybuffer
  24. */
  25. arrayBuffer(): Promise<ArrayBuffer>
  26. /** Not implemented
  27. *
  28. * https://fetch.spec.whatwg.org/#dom-body-formdata
  29. */
  30. formData(): Promise<never>
  31. /** Returns true if the body is not null and the body has been consumed
  32. *
  33. * Otherwise, returns false
  34. *
  35. * https://fetch.spec.whatwg.org/#dom-body-bodyused
  36. */
  37. readonly bodyUsed: boolean
  38. /** Throws on node 16.6.0
  39. *
  40. * If body is null, it should return null as the body
  41. *
  42. * If body is not null, should return the body as a ReadableStream
  43. *
  44. * https://fetch.spec.whatwg.org/#dom-body-body
  45. */
  46. readonly body: never | undefined
  47. /** Dumps the response body by reading `limit` number of bytes.
  48. * @param opts.limit Number of bytes to read (optional) - Default: 262144
  49. */
  50. dump(opts?: { limit: number }): Promise<void>
  51. }