bare-tty 1.0.5 → 1.0.7
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/binding.c +8 -1
- package/index.js +15 -15
- package/package.json +1 -1
package/binding.c
CHANGED
|
@@ -157,7 +157,7 @@ on_read (uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
|
|
|
157
157
|
assert(err == 0);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
js_call_function(env, ctx, on_read,
|
|
160
|
+
js_call_function(env, ctx, on_read, 2, argv, NULL);
|
|
161
161
|
|
|
162
162
|
err = js_close_handle_scope(env, scope);
|
|
163
163
|
assert(err == 0);
|
|
@@ -243,6 +243,13 @@ bare_tty_init (js_env_t *env, js_callback_info_t *info) {
|
|
|
243
243
|
return NULL;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
err = uv_stream_set_blocking((uv_stream_t *) &tty->handle, true);
|
|
247
|
+
|
|
248
|
+
if (err < 0) {
|
|
249
|
+
js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
250
|
+
return NULL;
|
|
251
|
+
}
|
|
252
|
+
|
|
246
253
|
tty->env = env;
|
|
247
254
|
|
|
248
255
|
err = js_get_typedarray_info(env, argv[1], NULL, (void **) &tty->read.base, &tty->read.len, NULL, NULL);
|
package/index.js
CHANGED
|
@@ -14,9 +14,9 @@ module.exports = exports = class TTY extends Duplex {
|
|
|
14
14
|
allowHalfOpen = true
|
|
15
15
|
} = opts
|
|
16
16
|
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
17
|
+
this._pendingWrite = null
|
|
18
|
+
this._pendingFinal = null
|
|
19
|
+
this._pendingDestroy = null
|
|
20
20
|
|
|
21
21
|
this._allowHalfOpen = allowHalfOpen
|
|
22
22
|
|
|
@@ -36,38 +36,38 @@ module.exports = exports = class TTY extends Duplex {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
_writev (datas, cb) {
|
|
39
|
-
this.
|
|
39
|
+
this._pendingWrite = cb
|
|
40
40
|
binding.writev(this._handle, datas)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
_final (cb) {
|
|
44
|
-
this.
|
|
44
|
+
this._pendingFinal = cb
|
|
45
45
|
binding.end(this._handle)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
_destroy (cb) {
|
|
49
|
-
this.
|
|
49
|
+
this._pendingDestroy = cb
|
|
50
50
|
binding.close(this._handle)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
_continueWrite (err) {
|
|
54
|
-
if (this.
|
|
55
|
-
const cb = this.
|
|
56
|
-
this.
|
|
54
|
+
if (this._pendingWrite === null) return
|
|
55
|
+
const cb = this._pendingWrite
|
|
56
|
+
this._pendingWrite = null
|
|
57
57
|
cb(err)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
_continueFinal (err) {
|
|
61
|
-
if (this.
|
|
62
|
-
const cb = this.
|
|
63
|
-
this.
|
|
61
|
+
if (this._pendingFinal === null) return
|
|
62
|
+
const cb = this._pendingFinal
|
|
63
|
+
this._pendingFinal = null
|
|
64
64
|
cb(err)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
_continueDestroy () {
|
|
68
|
-
if (this.
|
|
69
|
-
const cb = this.
|
|
70
|
-
this.
|
|
68
|
+
if (this._pendingDestroy === null) return
|
|
69
|
+
const cb = this._pendingDestroy
|
|
70
|
+
this._pendingDestroy = null
|
|
71
71
|
cb(null)
|
|
72
72
|
}
|
|
73
73
|
|