-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream: expose stream symbols #45671
stream: expose stream symbols #45671
Conversation
Review requested:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
9b479d6
Compare
const kKey = Symbol('key')
class My { [kKey]() { console.log('hello') }}
const [, symKey] = Reflect.ownKeys(My.prototype)
new My()[symKey]()
// hello |
The symbols are not an a prototype... |
They also work in objects, don't they? const obj = { [Symbol("test")]: 'hey' }
const [symbol] = Reflect.ownKeys(obj)
console.log(obj[symbol]) // hey For Streams: const str = stream.Readable.from('abc')
const data = Reflect.ownKeys(str)
const kCapture = data[6]
str[kCapture] // false |
I still don't see how that will work. Would need to know the static index of the symbol. Which is not possible atm. |
This case is similar to |
Why don't we use a regular string key to expose these values like what was done in the case of |
@nodejs/streams some reviews? |
@mcollina We will need this in readable-stream for proper interop. |
Adding the
tsc-agenda
|
Commit Queue failed- Loading data for nodejs/node/pull/45671 ✔ Done loading data for nodejs/node/pull/45671 ----------------------------------- PR info ------------------------------------ Title stream: expose stream symbols (#45671) Author Robert Nagy (@ronag) Branch ronag:expose-stream-symbols -> nodejs:main Labels stream, author ready Commits 1 - stream: expose stream symbols Committers 1 - Robert Nagy PR-URL: https://github.com/nodejs/node/pull/45671 Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel Reviewed-By: Benjamin Gruenbaum ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/45671 Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel Reviewed-By: Benjamin Gruenbaum -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last review: ⚠ - stream: expose stream symbols ℹ This PR was created on Tue, 29 Nov 2022 10:33:01 GMT ✔ Approvals: 4 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/45671#pullrequestreview-1307877767 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/45671#pullrequestreview-1223224391 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/45671#pullrequestreview-1240689090 ✔ - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/45671#pullrequestreview-1318093984 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2023-01-05T18:00:02Z: https://ci.nodejs.org/job/node-test-pull-request/48871/ ⚠ Commits were pushed after the last Full PR CI run: ⚠ - stream: expose stream symbols - Querying data for job/node-test-pull-request/48871/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/4382938745 |
This comment was marked as outdated.
This comment was marked as outdated.
Landed in 8c60add |
Note: I believe this change requires an update to the documentation as well. |
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Debadree Chatterjee <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Debadree Chatterjee <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Debadree Chatterjee <[email protected]>
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.