55The ` tty ` module houses the ` tty.ReadStream ` and ` tty.WriteStream ` classes. In
66most cases, you will not need to use this module directly.
77
8- When Node.js detects that it is being run inside a TTY context, then ` process.stdin `
9- will be a ` tty.ReadStream ` instance and ` process.stdout ` will be
8+ When Node.js detects that it is being run inside a TTY context, then
9+ ` process.stdin ` will be a ` tty.ReadStream ` instance and ` process.stdout ` will be
1010a ` tty.WriteStream ` instance. The preferred way to check if Node.js is being run
1111in a TTY context is to check ` process.stdout.isTTY ` :
1212
@@ -25,8 +25,8 @@ Node.js program (only when `isatty(0)` is true).
2525
2626### rs.isRaw
2727
28- A ` Boolean ` that is initialized to ` false ` . It represents the current "raw" state
29- of the ` tty.ReadStream ` instance.
28+ A ` Boolean ` that is initialized to ` false ` . It represents the current "raw"
29+ state of the ` tty.ReadStream ` instance.
3030
3131### rs.setRawMode(mode)
3232
@@ -40,6 +40,17 @@ A `net.Socket` subclass that represents the writable portion of a tty. In normal
4040circumstances, ` process.stdout ` will be the only ` tty.WriteStream ` instance
4141ever created (and only when ` isatty(1) ` is true).
4242
43+ ### Constructor: new fs.WriteStream(fd[ , options] )
44+
45+ * ` fd ` {Number} The numeric file descriptor for this TTY instance.
46+ * ` options ` {Object}
47+ * ` blocking ` {boolean} ` true ` if writes to the TTY should be blocking,
48+ ` false ` otherwise. Defaults to ` true ` .
49+
50+ Creates a new ` tty.WriteStream ` . By default, writes to the TTY will be blocking.
51+ Use ` new fs.WriteStream(fd, {blocking: false}) ` to create the ` fs.WriteStream `
52+ using non-blocking writes by default.
53+
4354### Event: 'resize'
4455
4556` function () {} `
@@ -64,6 +75,17 @@ gets updated on `'resize'` events.
6475A ` Number ` that gives the number of rows the TTY currently has. This property
6576gets updated on ` 'resize' ` events.
6677
78+ ### ws.setNonBlocking([ bool] )
79+
80+ * ` bool ` {boolean} ` true ` to set the TTY to non-blocking writes, ` false `
81+ otherwise. Defaults to ` true ` .
82+
83+ Returns a reference to the ` tty.WriteStream ` so calls can be chained.
84+
85+ ``` js
86+ const myNonBlockingTTY = new tty.WriteStream (myFd).setNonBlocking ();
87+ ```
88+
6789## tty.isatty(fd)
6890
6991Returns ` true ` or ` false ` depending on if the ` fd ` is associated with a
0 commit comments