Skip to content

Commit

Permalink
readline: replace _questionCancel with a symbol
Browse files Browse the repository at this point in the history
This commit avoids exposing a new underscored property on
readline Interface instances.

PR-URL: #37094
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cjihrig authored and Lxxyx committed Jan 29, 2021
1 parent b02030d commit fec093b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const kMincrlfDelay = 100;
const lineEnding = /\r?\n|\r(?!\n)/;

const kLineObjectStream = Symbol('line object stream');
const kQuestionCancel = Symbol('kQuestionCancel');

const KEYPRESS_DECODER = Symbol('keypress-decoder');
const ESCAPE_DECODER = Symbol('escape-decoder');
Expand Down Expand Up @@ -225,7 +226,7 @@ function Interface(input, output, completer, terminal) {
};
}

this._questionCancel = FunctionPrototypeBind(_questionCancel, this);
this[kQuestionCancel] = FunctionPrototypeBind(_questionCancel, this);

this.setPrompt(prompt);

Expand Down Expand Up @@ -376,7 +377,7 @@ Interface.prototype.question = function(query, options, cb) {

if (options.signal) {
options.signal.addEventListener('abort', () => {
this._questionCancel();
this[kQuestionCancel]();
}, { once: true });
}

Expand Down

0 comments on commit fec093b

Please sign in to comment.