bare-tty 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +21 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -25,6 +25,8 @@ exports.ReadStream = class TTYReadStream extends Readable {
|
|
|
25
25
|
this._onread,
|
|
26
26
|
this._onclose
|
|
27
27
|
)
|
|
28
|
+
|
|
29
|
+
TTYReadStream._streams.add(this)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
get isTTY () {
|
|
@@ -46,6 +48,7 @@ exports.ReadStream = class TTYReadStream extends Readable {
|
|
|
46
48
|
_destroy (cb) {
|
|
47
49
|
this._pendingDestroy = cb
|
|
48
50
|
binding.close(this._handle)
|
|
51
|
+
TTYReadStream._streams.delete(this)
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
_continueDestroy () {
|
|
@@ -80,6 +83,8 @@ exports.ReadStream = class TTYReadStream extends Readable {
|
|
|
80
83
|
this._handle = null
|
|
81
84
|
this._continueDestroy()
|
|
82
85
|
}
|
|
86
|
+
|
|
87
|
+
static _streams = new Set()
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
exports.WriteStream = class TTYWriteStream extends Writable {
|
|
@@ -96,6 +101,8 @@ exports.WriteStream = class TTYWriteStream extends Writable {
|
|
|
96
101
|
noop,
|
|
97
102
|
this._onclose
|
|
98
103
|
)
|
|
104
|
+
|
|
105
|
+
TTYWriteStream._streams.add(this)
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
get isTTY () {
|
|
@@ -119,6 +126,7 @@ exports.WriteStream = class TTYWriteStream extends Writable {
|
|
|
119
126
|
_destroy (cb) {
|
|
120
127
|
this._pendingDestroy = cb
|
|
121
128
|
binding.close(this._handle)
|
|
129
|
+
TTYWriteStream._streams.delete(this)
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
_continueWrite (err) {
|
|
@@ -175,6 +183,8 @@ exports.WriteStream = class TTYWriteStream extends Writable {
|
|
|
175
183
|
this._handle = null
|
|
176
184
|
this._continueDestroy()
|
|
177
185
|
}
|
|
186
|
+
|
|
187
|
+
static _streams = new Set()
|
|
178
188
|
}
|
|
179
189
|
|
|
180
190
|
exports.constants = {
|
|
@@ -183,6 +193,17 @@ exports.constants = {
|
|
|
183
193
|
MODE_IO: binding.MODE_IO || 0
|
|
184
194
|
}
|
|
185
195
|
|
|
196
|
+
process
|
|
197
|
+
.on('exit', () => {
|
|
198
|
+
for (const stream of exports.ReadStream._streams) {
|
|
199
|
+
stream.destroy()
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
for (const stream of exports.WriteStream._streams) {
|
|
203
|
+
stream.destroy()
|
|
204
|
+
}
|
|
205
|
+
})
|
|
206
|
+
|
|
186
207
|
const empty = Buffer.alloc(0)
|
|
187
208
|
|
|
188
209
|
function noop () {}
|