From c4fdc85a92f9d04c8e9b6460de0cd63b69b03a78 Mon Sep 17 00:00:00 2001 From: Renegade334 Date: Mon, 2 Feb 2026 00:57:33 +0000 Subject: [PATCH 1/2] stream: rename `Duplex.toWeb()` type option to `readableType` --- doc/api/stream.md | 11 ++++++++--- lib/internal/webstreams/adapters.js | 14 ++++++++++---- test/parallel/test-stream-duplex.js | 6 +++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index ef6dd51eabfd5e..6cd97093b931c8 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -3219,7 +3219,8 @@ changes: If no value is provided, the size will be `1` for all the chunks. * `chunk` {any} * Returns: {number} - * `type` {string} Must be 'bytes' or undefined. + * `type` {string} Specifies the type of the created `ReadableStream`. Must be + `'bytes'` or undefined. * Returns: {ReadableStream} ### `stream.Writable.fromWeb(writableStream[, options])` @@ -3398,9 +3399,12 @@ duplex.once('readable', () => console.log('readable', duplex.read())); + +Type: Documentation-only + +Passing the `type` option to [`Duplex.toWeb()`][] is deprecated. To specify the +type of the readable half of the constructed readable-writable pair, use the +`readableType` option instead. + [DEP0142]: #dep0142-repl_builtinlibs [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 @@ -4406,6 +4421,7 @@ import { opendir } from 'node:fs/promises'; [`Buffer.isBuffer()`]: buffer.md#static-method-bufferisbufferobj [`Cipheriv`]: crypto.md#class-cipheriv [`Decipheriv`]: crypto.md#class-decipheriv +[`Duplex.toWeb()`]: stream.md#streamduplextowebstreamduplex-options [`Error.isError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/isError [`REPLServer.clearBufferedCommand()`]: repl.md#replserverclearbufferedcommand [`ReadStream.open()`]: fs.md#class-fsreadstream diff --git a/doc/api/stream.md b/doc/api/stream.md index 6cd97093b931c8..73009939fe721b 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -3401,7 +3401,8 @@ added: v17.0.0 changes: - version: REPLACEME pr-url: https://github.com/nodejs/node/pull/61632 - description: The 'type' option is renamed to 'readableType'. + description: Added the 'readableType' option to specify the ReadableStream + type. The 'type' option is deprecated. - version: v25.4.0 pr-url: https://github.com/nodejs/node/pull/58664 description: Added the 'type' option to specify the ReadableStream type. @@ -3416,6 +3417,7 @@ changes: * `options` {Object} * `readableType` {string} Specifies the type of the `ReadableStream` half of the created readable-writable pair. Must be `'bytes'` or undefined. + (`options.type` is a deprecated alias for this option.) * Returns: {Object} * `readable` {ReadableStream} * `writable` {WritableStream} diff --git a/lib/internal/webstreams/adapters.js b/lib/internal/webstreams/adapters.js index b442262f7bc26c..ed9847f250f1ca 100644 --- a/lib/internal/webstreams/adapters.js +++ b/lib/internal/webstreams/adapters.js @@ -643,7 +643,7 @@ function newReadableWritablePairFromDuplex(duplex, options = kEmptyObject) { const readableOptions = { __proto__: null, - // 'options.type' is a legacy alias for 'options.readableType' + // DEP0201: 'options.type' is a deprecated alias for 'options.readableType' type: options.readableType ?? options.type, };