| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b4ea323 commit ac63754
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4431,12 +4431,15 @@ import { opendir } from 'node:fs/promises'; | |||
| 4431 | 4431 | ||
| 4432 | 4432 | <!-- YAML | |
| 4433 | 4433 | changes: | |
| 4434 | + - version: REPLACEME | ||
| 4435 | + pr-url: https://github.com/nodejs/node/pull/62173 | ||
| 4436 | + description: Runtime deprecation. | ||
| 4434 | 4437 | - version: v25.7.0 | |
| 4435 | 4438 | pr-url: https://github.com/nodejs/node/pull/61632 | |
| 4436 | 4439 | description: Documentation-only deprecation. | |
| 4437 | 4440 | --> | |
| 4438 | 4441 | ||
| 4439 | - Type: Documentation-only | ||
| 4442 | + Type: Runtime | ||
| 4440 | 4443 | ||
| 4441 | 4444 | Passing the `type` option to [`Duplex.toWeb()`][] is deprecated. To specify the | |
| 4442 | 4445 | type of the readable half of the constructed readable-writable pair, use the | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,6 +71,7 @@ const { | |||
| 71 | 71 | } = require('internal/errors'); | |
| 72 | 72 | ||
| 73 | 73 | const { | |
| 74 | + getDeprecationWarningEmitter, | ||
| 74 | 75 | kEmptyObject, | |
| 75 | 76 | normalizeEncoding, | |
| 76 | 77 | } = require('internal/util'); | |
@@ -650,6 +651,12 @@ function newStreamReadableFromReadableStream(readableStream, options = kEmptyObj | |||
| 650 | 651 | return readable; | |
| 651 | 652 | } | |
| 652 | 653 | ||
| 654 | + const emitDEP0201 = getDeprecationWarningEmitter( | ||
| 655 | + 'DEP0201', | ||
| 656 | + "Passing 'options.type' to Duplex.toWeb() is deprecated. " + | ||
| 657 | + "To specify the ReadableStream type, use 'options.readableType'.", | ||
| 658 | + newReadableWritablePairFromDuplex); | ||
| 659 | + | ||
| 653 | 660 | /** | |
| 654 | 661 | * @typedef {import('./readablestream').ReadableWritablePair | |
| 655 | 662 | * } ReadableWritablePair | |
@@ -677,10 +684,15 @@ function newReadableWritablePairFromDuplex(duplex, options = kEmptyObject) { | |||
| 677 | 684 | ||
| 678 | 685 | const readableOptions = { | |
| 679 | 686 | __proto__: null, | |
| 680 | - // DEP0201: 'options.type' is a deprecated alias for 'options.readableType' | ||
| 681 | - type: options.readableType ?? options.type, | ||
| 687 | + type: options.readableType, | ||
| 682 | 688 | }; | |
| 683 | 689 | ||
| 690 | + if (options.readableType == null && options.type != null) { | ||
| 691 | + // 'options.type' is a deprecated alias for 'options.readableType' | ||
| 692 | + emitDEP0201(); | ||
| 693 | + readableOptions.type = options.type; | ||
| 694 | + } | ||
| 695 | + | ||
| 684 | 696 | if (isDestroyed(duplex)) { | |
| 685 | 697 | const writable = new WritableStream(); | |
| 686 | 698 | const readable = new ReadableStream({ type: readableOptions.type }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,4 +157,6 @@ process.on('exit', () => { | |||
| 157 | 157 | // Ensure that the originally-named `options.type` still works as an alias for `options.readableType` | |
| 158 | 158 | // `getReader({ mode: 'byob' })` throws if the underlying ReadableStream is not a byte stream | |
| 159 | 159 | Duplex.toWeb(duplex, { type: 'bytes' }).readable.getReader({ mode: 'byob' }); | |
| 160 | + common.expectWarning('DeprecationWarning', | ||
| 161 | + [/Passing 'options\.type' to Duplex\.toWeb\(\) is deprecated/, 'DEP0201']); | ||
| 160 | 162 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments