Skip to content

Commit

Permalink
repl: simplify code
Browse files Browse the repository at this point in the history
This simplifies some repl code and removes a code branch that is
unreachable.

PR-URL: #30907
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
BridgeAR authored and MylesBorins committed Dec 17, 2019
1 parent f7eeb8c commit 8b92223
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ REPLServer.prototype.createContext = function() {
}

const module = new CJSModule('<repl>');
module.paths = CJSModule._resolveLookupPaths('<repl>', parentModule) || [];
module.paths = CJSModule._resolveLookupPaths('<repl>', parentModule);

ObjectDefineProperty(context, 'module', {
configurable: true,
Expand Down Expand Up @@ -1307,21 +1307,17 @@ function complete(line, callback) {
}
// Works for non-objects
try {
let sentinel = 5;
let p;
if (typeof obj === 'object' || typeof obj === 'function') {
p = ObjectGetPrototypeOf(obj);
} else {
p = obj.constructor ? obj.constructor.prototype : null;
}
while (p !== null) {
// Circular refs possible? Let's guard against that.
let sentinel = 5;
while (p !== null && sentinel-- !== 0) {
memberGroups.push(filteredOwnPropertyNames(p));
p = ObjectGetPrototypeOf(p);
// Circular refs possible? Let's guard against that.
sentinel--;
if (sentinel <= 0) {
break;
}
}
} catch {}
}
Expand Down

0 comments on commit 8b92223

Please sign in to comment.