From 1714998e2c9526bd2cfecf6039b2d8520077b892 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 26 Jan 2021 22:42:13 -0500 Subject: [PATCH] readline: replace _questionCancel with a symbol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit avoids exposing a new underscored property on readline Interface instances. PR-URL: https://github.com/nodejs/node/pull/37094 Reviewed-By: Zijian Liu Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- lib/readline.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index 1793cb21264df1..38ddebaa4917ca 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -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'); @@ -225,7 +226,7 @@ function Interface(input, output, completer, terminal) { }; } - this._questionCancel = FunctionPrototypeBind(_questionCancel, this); + this[kQuestionCancel] = FunctionPrototypeBind(_questionCancel, this); this.setPrompt(prompt); @@ -368,7 +369,7 @@ Interface.prototype.question = function(query, options, cb) { if (options.signal) { options.signal.addEventListener('abort', () => { - this._questionCancel(); + this[kQuestionCancel](); }, { once: true }); }