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 <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
cjihrig authored and targos committed Feb 2, 2021
1 parent 3d64d2b commit 1714998
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 @@ -368,7 +369,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 1714998

Please sign in to comment.