From f7eeb8cc0b6d5843874789e8326272849029408a Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 10 Dec 2019 17:31:13 +0100 Subject: [PATCH] repl: simplify repl autocompletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This simplifies calling `filteredOwnPropertyNames()`. The context is not used in that function, so there's no need to call the function as such. PR-URL: https://github.com/nodejs/node/pull/30907 Reviewed-By: Michaƫl Zasso Reviewed-By: Rich Trott --- lib/repl.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index 5d932dda3f7052..eeee83fee3c70f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1280,11 +1280,9 @@ function complete(line, callback) { completionGroups.push(getGlobalLexicalScopeNames(this[kContextId])); let contextProto = this.context; while (contextProto = ObjectGetPrototypeOf(contextProto)) { - completionGroups.push( - filteredOwnPropertyNames.call(this, contextProto)); + completionGroups.push(filteredOwnPropertyNames(contextProto)); } - const contextOwnNames = - filteredOwnPropertyNames.call(this, this.context); + const contextOwnNames = filteredOwnPropertyNames(this.context); if (!this.useGlobal) { // When the context is not `global`, builtins are not own // properties of it. @@ -1299,7 +1297,7 @@ function complete(line, callback) { if (obj != null) { if (typeof obj === 'object' || typeof obj === 'function') { try { - memberGroups.push(filteredOwnPropertyNames.call(this, obj)); + memberGroups.push(filteredOwnPropertyNames(obj)); } catch { // Probably a Proxy object without `getOwnPropertyNames` trap. // We simply ignore it here, as we don't want to break the @@ -1317,7 +1315,7 @@ function complete(line, callback) { p = obj.constructor ? obj.constructor.prototype : null; } while (p !== null) { - memberGroups.push(filteredOwnPropertyNames.call(this, p)); + memberGroups.push(filteredOwnPropertyNames(p)); p = ObjectGetPrototypeOf(p); // Circular refs possible? Let's guard against that. sentinel--;