Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: implement fetch body mixin on Readable #39520

Closed
wants to merge 17 commits into from
71 changes: 71 additions & 0 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,8 @@ added: v0.9.4

<!--type=class-->

`Readable` implements the body mixin API from the [fetch specification][].

##### Event: `'close'`
<!-- YAML
added: v0.9.4
Expand Down Expand Up @@ -986,6 +988,51 @@ added: v0.9.4
The `'resume'` event is emitted when [`stream.resume()`][stream-resume] is
called and `readableFlowing` is not `true`.

##### `readable.arrayBuffer()`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* Returns: {Promise}

Returns a promise fulfilled with the full content as an {ArrayBuffer}.

##### `readable.blob()`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* Returns: {Promise}

Returns a promise fulfilled with the full content as a {Blob}.

##### `readable.body`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* Returns: {ReadableStream}

Returns a `ReadableStream`.

##### `readable.bodyUsed`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* Returns: {boolean}

Returns true if stream has emitted `'data'`, `'end'`, `'error'` or
`'close'`.

##### `readable.destroy([error])`
<!-- YAML
added: v8.0.0
Expand Down Expand Up @@ -1040,6 +1087,18 @@ readable.resume();
readable.isPaused(); // === false
```

##### `readable.json()`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* Returns: {Promise}

Returns a promise fulfilled with the full content read as an UTF-8
string and parsed as a JSON object.

##### `readable.pause()`
<!-- YAML
added: v0.9.4
Expand Down Expand Up @@ -1341,6 +1400,17 @@ readable.on('data', (chunk) => {
});
```

##### `readable.text()`
<!-- YAML
added: REPLACEME
-->

> Stability: 1 - Experimental

* Returns: {Promise}

Returns a promise fulfilled with the full content read as an UTF-8 string.

##### `readable.unpipe([destination])`
<!-- YAML
added: v0.9.4
Expand Down Expand Up @@ -3503,6 +3573,7 @@ contain multi-byte characters.
[child process stdin]: child_process.md#child_process_subprocess_stdin
[child process stdout and stderr]: child_process.md#child_process_subprocess_stdout
[crypto]: crypto.md
[fetch specification]: https://fetch.spec.whatwg.org/#body-mixin
[fs read streams]: fs.md#fs_class_fs_readstream
[fs write streams]: fs.md#fs_class_fs_writestream
[http-incoming-message]: http.md#http_class_http_incomingmessage
Expand Down
Loading