5
5
The ` tty ` module houses the ` tty.ReadStream ` and ` tty.WriteStream ` classes. In
6
6
most cases, you will not need to use this module directly.
7
7
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
10
10
a ` tty.WriteStream ` instance. The preferred way to check if Node.js is being run
11
11
in a TTY context is to check ` process.stdout.isTTY ` :
12
12
@@ -25,8 +25,8 @@ Node.js program (only when `isatty(0)` is true).
25
25
26
26
### rs.isRaw
27
27
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.
30
30
31
31
### rs.setRawMode(mode)
32
32
@@ -40,6 +40,17 @@ A `net.Socket` subclass that represents the writable portion of a tty. In normal
40
40
circumstances, ` process.stdout ` will be the only ` tty.WriteStream ` instance
41
41
ever created (and only when ` isatty(1) ` is true).
42
42
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
+
43
54
### Event: 'resize'
44
55
45
56
` function () {} `
@@ -64,6 +75,17 @@ gets updated on `'resize'` events.
64
75
A ` Number ` that gives the number of rows the TTY currently has. This property
65
76
gets updated on ` 'resize' ` events.
66
77
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
+
67
89
## tty.isatty(fd)
68
90
69
91
Returns ` true ` or ` false ` depending on if the ` fd ` is associated with a
0 commit comments