Skip to content

readable.pipe returns stream.Readable #22341

Description

@andreasg123

readable.pipe is documented to return stream.Writable. However, as only stream.Readable has a pipe method, it only makes sense to return that to set up chains of piped streams. I also verified that a pipe to a Gunzip object could be used as a Readable stream.

Activity

  1. added
    questionIssues asking questions about Node.js.
    streamIssues and PRs related to Node.js streams.
    on Aug 15, 2018
  2. addaleax commented on Aug 15, 2018

    @addaleax
    Member

    Hi! Can you explain what you are asking here? While everything you said is accurate, it’s not clear what you would like to see changed (if anything).

    Chaining pipes using this method only makes sense if the target Writable also implements the Readable interface, yes. For Gunzip streams, or generally Duplex streams, that is the case.

    If the returned value is not a Readable instance, then chaining pipes won’t work, but it’s still a meaningful thing and may be helpful to have (e.g. event listeners can be installed on it).

    I think changing what .pipe() returns would be too big of a breaking change, in case that’s what you are suggesting here.

  3. andreasg123 commented on Aug 15, 2018

    @andreasg123
    ContributorAuthor

    I'm only asking to make the documentation a little clearer. I guess I should have checked the code to determine that the destination parameter to pipe is just the return value (currently not documented). I think that it would be beneficial to document explicitly that chaining pipes only works if the target Writable also implements the Readable interface. In the current documentation, it is confusing to understand why returning a Writable would support chaining.

    It would also be helpful to document that Gunzip implements both Readable and Writable. That's kind of implied but there is no documentation on the methods of this class or its siblings.

  4. added
    docIssues and PRs related to Node.js documentation.
    and removed
    questionIssues asking questions about Node.js.
    on Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.streamIssues and PRs related to Node.js streams.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions