mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
readline: add stricter validation for functions called after closed
PR-URL: https://github.com/nodejs/node/pull/57680 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
parent
68cc1c9cd3
commit
8e7f32f968
7 changed files with 73 additions and 14 deletions
|
@ -599,6 +599,9 @@ class Interface extends InterfaceConstructor {
|
|||
* @returns {void | Interface}
|
||||
*/
|
||||
pause() {
|
||||
if (this.closed) {
|
||||
throw new ERR_USE_AFTER_CLOSE('readline');
|
||||
}
|
||||
if (this.paused) return;
|
||||
this.input.pause();
|
||||
this.paused = true;
|
||||
|
@ -611,6 +614,9 @@ class Interface extends InterfaceConstructor {
|
|||
* @returns {void | Interface}
|
||||
*/
|
||||
resume() {
|
||||
if (this.closed) {
|
||||
throw new ERR_USE_AFTER_CLOSE('readline');
|
||||
}
|
||||
if (!this.paused) return;
|
||||
this.input.resume();
|
||||
this.paused = false;
|
||||
|
@ -631,6 +637,9 @@ class Interface extends InterfaceConstructor {
|
|||
* @returns {void}
|
||||
*/
|
||||
write(d, key) {
|
||||
if (this.closed) {
|
||||
throw new ERR_USE_AFTER_CLOSE('readline');
|
||||
}
|
||||
if (this.paused) this.resume();
|
||||
if (this.terminal) {
|
||||
this[kTtyWrite](d, key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue