bare-tty 2.1.2 → 2.1.4
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 +16 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ exports.ReadStream = class TTYReadStream extends Readable {
|
|
|
15
15
|
this._pendingDestroy = null
|
|
16
16
|
|
|
17
17
|
this._reading = false
|
|
18
|
+
this._closing = false
|
|
18
19
|
this._allowHalfOpen = allowHalfOpen
|
|
19
20
|
|
|
20
21
|
this._buffer = Buffer.alloc(readBufferSize)
|
|
@@ -46,13 +47,15 @@ exports.ReadStream = class TTYReadStream extends Readable {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
_predestroy () {
|
|
49
|
-
if (this.
|
|
50
|
+
if (this._closing) return
|
|
51
|
+
this._closing = true
|
|
50
52
|
binding.close(this._handle)
|
|
51
53
|
TTYReadStream._streams.delete(this)
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
_destroy (cb) {
|
|
55
|
-
if (this.
|
|
57
|
+
if (this._closing) return cb(null)
|
|
58
|
+
this._closing = true
|
|
56
59
|
this._pendingDestroy = cb
|
|
57
60
|
binding.close(this._handle)
|
|
58
61
|
TTYReadStream._streams.delete(this)
|
|
@@ -102,6 +105,8 @@ exports.WriteStream = class TTYWriteStream extends Writable {
|
|
|
102
105
|
this._pendingFinal = null
|
|
103
106
|
this._pendingDestroy = null
|
|
104
107
|
|
|
108
|
+
this._closing = false
|
|
109
|
+
|
|
105
110
|
this._handle = binding.init(fd, empty, this,
|
|
106
111
|
this._onwrite,
|
|
107
112
|
this._onfinal,
|
|
@@ -130,7 +135,16 @@ exports.WriteStream = class TTYWriteStream extends Writable {
|
|
|
130
135
|
binding.end(this._handle)
|
|
131
136
|
}
|
|
132
137
|
|
|
138
|
+
_predestroy () {
|
|
139
|
+
if (this._closing) return
|
|
140
|
+
this._closing = true
|
|
141
|
+
binding.close(this._handle)
|
|
142
|
+
TTYWriteStream._streams.delete(this)
|
|
143
|
+
}
|
|
144
|
+
|
|
133
145
|
_destroy (cb) {
|
|
146
|
+
if (this._closing) return cb(null)
|
|
147
|
+
this._closing = true
|
|
134
148
|
this._pendingDestroy = cb
|
|
135
149
|
binding.close(this._handle)
|
|
136
150
|
TTYWriteStream._streams.delete(this)
|