@@ -1149,13 +1149,85 @@ Sets the priority of the stream. Throws `ERR_INVALID_STATE` if the session
11491149does not support priority (e.g. non-HTTP/3). Has no effect if the stream
11501150has been destroyed.
11511151
1152- ### ` stream.readable `
1152+ ### ` stream[Symbol.asyncIterator]() `
11531153
11541154<!-- YAML
1155- added: v23.8.0
1155+ added: REPLACEME
11561156-->
11571157
1158- * Type: {ReadableStream}
1158+ * Returns: {AsyncIterableIterator} yielding {Uint8Array\[ ] }
1159+
1160+ The stream implements ` Symbol.asyncIterator ` , making it directly usable
1161+ in ` for await...of ` loops. Each iteration yields a batch of ` Uint8Array `
1162+ chunks.
1163+
1164+ Only one async iterator can be obtained per stream. A second call throws
1165+ ` ERR_INVALID_STATE ` . Non-readable streams (outbound-only unidirectional
1166+ or closed) return an immediately-finished iterator.
1167+
1168+ ``` mjs
1169+ for await (const chunks of stream ) {
1170+ for (const chunk of chunks) {
1171+ // Process each Uint8Array chunk
1172+ }
1173+ }
1174+ ```
1175+
1176+ Compatible with stream/iter utilities:
1177+
1178+ ``` mjs
1179+ import Stream from ' node:stream/iter' ;
1180+ const body = await Stream .bytes (stream);
1181+ const text = await Stream .text (stream);
1182+ await Stream .pipeTo (stream, someWriter);
1183+ ```
1184+
1185+ ### ` stream.writer `
1186+
1187+ <!-- YAML
1188+ added: REPLACEME
1189+ -->
1190+
1191+ * Type: {Object}
1192+
1193+ Returns a Writer object for pushing data to the stream incrementally.
1194+ The Writer implements the stream/iter Writer interface with the
1195+ try-sync-fallback-to-async pattern.
1196+
1197+ Only available when no ` body ` source was provided at creation time or via
1198+ [ ` stream.setBody() ` ] [ ] . Non-writable streams return an already-closed
1199+ Writer. Throws ` ERR_INVALID_STATE ` if the outbound is already configured.
1200+
1201+ The Writer has the following methods:
1202+
1203+ * ` writeSync(chunk) ` — Synchronous write. Returns ` true ` if accepted,
1204+ ` false ` if flow-controlled. Data is NOT accepted on ` false ` .
1205+ * ` write(chunk[, options]) ` — Async write with drain wait. ` options.signal `
1206+ is checked at entry but not observed during the write.
1207+ * ` writevSync(chunks) ` — Synchronous vectored write. All-or-nothing.
1208+ * ` writev(chunks[, options]) ` — Async vectored write.
1209+ * ` endSync() ` — Synchronous close. Returns total bytes or ` -1 ` .
1210+ * ` end([options]) ` — Async close.
1211+ * ` fail(reason) ` — Errors the stream (sends RESET\_ STREAM to peer).
1212+ * ` desiredSize ` — Available capacity in bytes, or ` null ` if closed/errored.
1213+
1214+ ### ` stream.setBody(body) `
1215+
1216+ <!-- YAML
1217+ added: REPLACEME
1218+ -->
1219+
1220+ * ` body ` {string|ArrayBuffer|SharedArrayBuffer|TypedArray|Blob|AsyncIterable|Iterable|Promise|null}
1221+
1222+ Sets the outbound body source for the stream. Can only be called once.
1223+ Mutually exclusive with [ ` stream.writer ` ] [ ] .
1224+
1225+ If ` body ` is ` null ` , the writable side is closed immediately (FIN sent).
1226+ If ` body ` is a ` Promise ` , it is awaited and the resolved value is used.
1227+ Other types are handled per their optimization tier (see below).
1228+
1229+ Throws ` ERR_INVALID_STATE ` if the outbound is already configured or if
1230+ the writer has been accessed.
11591231
11601232### ` stream.session `
11611233
@@ -2235,4 +2307,6 @@ added: v23.8.0
22352307[ `stream.onwanttrailers` ] : #streamonwanttrailers
22362308[ `stream.pendingTrailers` ] : #streampendingtrailers
22372309[ `stream.sendTrailers()` ] : #streamsendtrailersheaders
2310+ [ `stream.setBody()` ] : #streamsetbodybody
22382311[ `stream.setPriority()` ] : #streamsetpriorityoptions
2312+ [ `stream.writer` ] : #streamwriter
0 commit comments