Closed
Description
Some streams (e.g.fs
and net
) need to first asynchronously create resources before they can perform any work. Currently this is implemented in the different stream implementations which both makes things more difficult and error prone (e.g. 'open'
and 'ready'
are emitted after 'close'
). I suggest we provide a standardized way of achieving this.
This would allow further simplification and improved consistency for various stream implementations such as fs
and net
stream.
I propose the following API for this:
- a
stream._construct(cb)
endpoint (similar to_destroy(cb)
). - a
stream.ready
property indicating whether the stream is ready (currently this is calledpending
in some implementations). IncludingreadableReady
andwritableReady
accessors. - a
'ready'
event (currently this is called'open'
in some implementations).
See, nxtedition#2 for proof of concept.