From 1f4d4c0da87db42f97f43d8374967071fe85b37a Mon Sep 17 00:00:00 2001 From: Alexander Mills Date: Wed, 19 Sep 2018 11:09:25 -0700 Subject: [PATCH] tty: make `readStream.setRawMode()` return `this` PR-URL: https://github.com/nodejs/node/pull/22950 Fixes: https://github.com/nodejs/node/issues/22916 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Denys Otrishko --- doc/api/tty.md | 1 + lib/tty.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/tty.md b/doc/api/tty.md index cc95bfa9ae86ba..45b66abb9e832d 100644 --- a/doc/api/tty.md +++ b/doc/api/tty.md @@ -64,6 +64,7 @@ added: v0.7.7 raw device. If `false`, configures the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw` property will be set to the resulting mode. +* Returns: {this} - the read stream instance. Allows configuration of `tty.ReadStream` so that it operates as a raw device. diff --git a/lib/tty.js b/lib/tty.js index 4e78347c2d25ba..3cc2320e9695f1 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -71,9 +71,10 @@ ReadStream.prototype.setRawMode = function(flag) { const err = this._handle.setRawMode(flag); if (err) { this.emit('error', errors.errnoException(err, 'setRawMode')); - return; + return this; } this.isRaw = flag; + return this; }; function WriteStream(fd) {