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