Skip to content

Commit d5b843e

Browse files
committed
make fromWeb clearer
1 parent 6e692f7 commit d5b843e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Basic usage example:
180180

181181
#### `response.body`
182182

183-
Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html) which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you require a Node stream, it is possible to convert between the two using `.fromWeb()`.
183+
Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html) which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream.
184184

185185
```
186186
import {fetch} from 'undici';
@@ -191,6 +191,13 @@ Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v1
191191
}
192192
```
193193

194+
If you require a Node stream, it is possible to convert between the two using `.fromWeb()`.
195+
196+
```
197+
import {Readable} from 'node:stream';
198+
const readableNodeStream = Readable.fromWeb(response.body);
199+
```
200+
194201
#### Specification Compliance
195202

196203
This section documents parts of the [Fetch Standard](https://fetch.spec.whatwg.org) which Undici does

0 commit comments

Comments
 (0)