From 37066f03198b9b6583dc6de038f03b2b1fa78465 Mon Sep 17 00:00:00 2001 From: LiviaMedeiros Date: Sat, 21 May 2022 17:54:41 +0800 Subject: [PATCH] readline: use `kEmptyObject` PR-URL: https://github.com/nodejs/node/pull/43159 Reviewed-By: Matteo Collina Reviewed-By: Antoine du Hamel --- lib/internal/readline/interface.js | 3 ++- lib/readline.js | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/internal/readline/interface.js b/lib/internal/readline/interface.js index e50172f5628ccc..63383658879095 100644 --- a/lib/internal/readline/interface.js +++ b/lib/internal/readline/interface.js @@ -43,6 +43,7 @@ const { validateString, validateUint32, } = require('internal/validators'); +const { kEmptyObject } = require('internal/util'); const { inspect, getStringWidth, @@ -922,7 +923,7 @@ class Interface extends InterfaceConstructor { // Handle a write from the tty [kTtyWrite](s, key) { const previousKey = this[kPreviousKey]; - key = key || {}; + key = key || kEmptyObject; this[kPreviousKey] = key; // Activate or deactivate substring search. diff --git a/lib/readline.js b/lib/readline.js index fa21c82f7158c2..7e55c99e65be23 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -100,7 +100,10 @@ const { kSubstringSearch, } = require('internal/readline/utils'); -const { promisify } = require('internal/util'); +const { + kEmptyObject, + promisify, +} = require('internal/util'); const { StringDecoder } = require('string_decoder'); @@ -987,7 +990,7 @@ Interface.prototype._moveCursor = function(dx) { }; function _ttyWriteDumb(s, key) { - key = key || {}; + key = key || kEmptyObject; if (key.name === 'escape') return;