Skip to content

process.stdin.setRawMode(true) does not return process.stdin? #22916

Description

@ORESoftware

I have this:

process.stdin.setRawMode(true);

but I cannot use it like so:

process.stdin.setRawMode(true).on('data' fn);

just curious if that is true and why that is. It could just be that the TypeScript typings are wrong.
Anyway, I would expect that process.stdin.setRawMode() would return the same thing as process.stdin.setEncoding().

Activity

  1. vsemozhetbyt commented on Sep 17, 2018

    @vsemozhetbyt
    Contributor

    FWIW, these signatures are documented differently:

    https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode
    https://nodejs.org/api/stream.html#stream_readable_setencoding_encoding

    And .setRawMode() does not return this:

    node/lib/tty.js

    Lines 69 to 73 in bb9d788

    ReadStream.prototype.setRawMode = function(flag) {
    flag = !!flag;
    this._handle.setRawMode(flag);
    this.isRaw = flag;
    };

  2. ORESoftware commented on Sep 17, 2018

    @ORESoftware
    ContributorAuthor

    yeah it should right, why not. Shouldn't break anybody to return this right?

  3. addaleax commented on Sep 18, 2018

    @addaleax
    Member

    @ORESoftware Yes, I think this would be okay to add – do you want to open a PR maybe?

  4. ORESoftware commented on Sep 18, 2018

    @ORESoftware
    ContributorAuthor

    sure I can do that, I would also want to update the TypeScript typings for this

  5. Fishrock123 commented on Sep 21, 2018

    @Fishrock123
    Contributor

    I would also want to update the TypeScript typings for this

    I don't think we maintain those but the actual change seems fine to me.

  6. added
    ttyIssues and PRs related to the tty subsystem.
    on Sep 21, 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

    ttyIssues and PRs related to the tty subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions