Uh oh!
There was an error while loading. Please reload this page.
stream: expose stream symbols - #45671
Conversation
nodejs-github-bot
commented
Nov 29, 2022
Review requested:
|
aduh95
left a comment
There was a problem hiding this comment.
If we expose them, we would need to document them. I don't think we want to do that, making symbols part of the public API goes against the idea of using symbols. Can't readable-stream use Reflect.ownKeys or Object.getOwnPropertySymbols to achieve that?
How would it do that? I'm not sure how that would work. Especially in a performant way. |
3d26201 to
9b479d6CompareErickWendel
commented
Nov 29, 2022
constkKey=Symbol('key')classMy{[kKey](){console.log('hello')}}const[,symKey]=Reflect.ownKeys(My.prototype)newMy()[symKey]()// hello |
The symbols are not an a prototype... |
They also work in objects, don't they? constobj={[Symbol("test")]: 'hey'}const[symbol]=Reflect.ownKeys(obj)console.log(obj[symbol])// heyFor Streams: conststr=stream.Readable.from('abc')constdata=Reflect.ownKeys(str)constkCapture=data[6]str[kCapture]// false |
ronag
commented
Nov 29, 2022
I still don't see how that will work. Would need to know the static index of the symbol. Which is not possible atm. |
vweevers
commented
Nov 29, 2022
This case is similar to |
RaisinTen
commented
Nov 30, 2022
Why don't we use a regular string key to expose these values like what was done in the case of |
nodejs-github-bot
commented
Nov 30, 2022
ronag
commented
Dec 19, 2022
@nodejs/streams some reviews? |
@mcollina We will need this in readable-stream for proper interop. |
aduh95
commented
Dec 19, 2022
Adding the
tsc-agenda |
This comment was marked as outdated.
This comment was marked as outdated.
nodejs-github-bot
commented
Mar 16, 2023
nodejs-github-bot
commented
Mar 18, 2023
nodejs-github-bot
commented
Mar 18, 2023
nodejs-github-bot
commented
Mar 24, 2023
Landed in 8c60add |
anonrig
commented
Mar 24, 2023
Note: I believe this change requires an update to the documentation as well. |
ronag
commented
Mar 24, 2023
This is not intended as a public api. |
This is required for streams interop with e.g. readable-stream. Currently readable-stream helpers will not work with normal node streams which is confusing and bad for the ecosystem. PR-URL: #45671 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This is required for streams interop with e.g. readable-stream. Currently readable-stream helpers will not work with normal node streams which is confusing and bad for the ecosystem. PR-URL: #45671 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This is required for streams interop with e.g. readable-stream. Currently readable-stream helpers will not work with normal node streams which is confusing and bad for the ecosystem. PR-URL: #45671 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
`stream.isDestroyed()` has been exported since v19.9.0 but was never documented, while its siblings `isErrored()`, `isReadable()` and `isWritable()` all have entries in `doc/api/stream.md`. Unlike those, `isDestroyed()` rejects Web streams: it returns `null` for anything that is not a Node.js stream. The accepted types are therefore documented as `Readable|Writable|Duplex` rather than also listing `ReadableStream`/`WritableStream`. Refs: nodejs#45671 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: YspritanHyzygy <yspritan@gmail.com>
`stream.isDestroyed()` has been exported since v19.9.0 but was never documented, while its siblings `isErrored()`, `isReadable()` and `isWritable()` all have entries in `doc/api/stream.md`. Unlike those, `isDestroyed()` rejects Web streams: it returns `null` for anything that is not a Node.js stream. The accepted types are therefore documented as `Readable|Writable|Duplex` rather than also listing `ReadableStream`/`WritableStream`. Refs: #45671 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: YspritanHyzygy <yspritan@gmail.com> PR-URL: #64789 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
`stream.isDestroyed()` has been exported since v19.9.0 but was never documented, while its siblings `isErrored()`, `isReadable()` and `isWritable()` all have entries in `doc/api/stream.md`. Unlike those, `isDestroyed()` rejects Web streams: it returns `null` for anything that is not a Node.js stream. The accepted types are therefore documented as `Readable|Writable|Duplex` rather than also listing `ReadableStream`/`WritableStream`. Refs: #45671 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: YspritanHyzygy <yspritan@gmail.com> PR-URL: #64789 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
`stream.isDestroyed()` has been exported since v19.9.0 but was never documented, while its siblings `isErrored()`, `isReadable()` and `isWritable()` all have entries in `doc/api/stream.md`. Unlike those, `isDestroyed()` rejects Web streams: it returns `null` for anything that is not a Node.js stream. The accepted types are therefore documented as `Readable|Writable|Duplex` rather than also listing `ReadableStream`/`WritableStream`. Refs: #45671 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: YspritanHyzygy <yspritan@gmail.com> PR-URL: #64789 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
`stream.isDestroyed()` has been exported since v19.9.0 but was never documented, while its siblings `isErrored()`, `isReadable()` and `isWritable()` all have entries in `doc/api/stream.md`. Unlike those, `isDestroyed()` rejects Web streams: it returns `null` for anything that is not a Node.js stream. The accepted types are therefore documented as `Readable|Writable|Duplex` rather than also listing `ReadableStream`/`WritableStream`. Refs: #45671 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: YspritanHyzygy <yspritan@gmail.com> PR-URL: #64789 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
`stream.isDestroyed()` has been exported since v19.9.0 but was never documented, while its siblings `isErrored()`, `isReadable()` and `isWritable()` all have entries in `doc/api/stream.md`. Unlike those, `isDestroyed()` rejects Web streams: it returns `null` for anything that is not a Node.js stream. The accepted types are therefore documented as `Readable|Writable|Duplex` rather than also listing `ReadableStream`/`WritableStream`. Refs: #45671 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: YspritanHyzygy <yspritan@gmail.com> PR-URL: #64789 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This is required for streams interop with e.g. readable-stream. Currently readable-stream helpers will not work with normal node streams which is confusing and bad for the ecosystem.