-
-
Notifications
You must be signed in to change notification settings - Fork 139
Description
In nodejs/node#445, the streams WG was tasked to remove the access of _writableState
and _readableState
across the various areas of core.
Three approaches are possible:
a. leave _writableState and _readableState as is, and just document them. A variation is to remap them without the _, but keep them in the same object. This would cause to expose a lot of other properties we do not need.
b. expose the part of the state as properties/getters on the stream object themselves, with the disadvantage that the streams would get some more properties.
c. allocate a new object for writableState and readableState and use getters there to link them to the _writableState and _readableState. This would force the creation of 2 more objects for each Duplex, and the allocation of a stream is already slow. Plus, it creates more references to clean up by the GC.
For the Streams WG, the best choice is option b), followed by option a) (do nothing).
In nodejs/node#445 and nodejs/node#12857 @mscdex expressed a formal -1 on the approach, preferring option c).
We should vote on the following:
- Can we add readableLength and writableLength to Readable and Writable respectively stream: remove {writeableState/readableState}.length node#12857?
- Can we add other properties like the above to Readable and Writable do remove the need to access _readableState and _writableState Cleanup
_writableState
and_readableState
access across codebase node#445?