Skip to content

Commit 876ab6e

Browse files
committed
update after reviewing again
1 parent 59649f3 commit 876ab6e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lib/repl.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ function intFilter(item) {
690690
return /^[A-Za-z_$]/.test(item);
691691
}
692692

693-
const DEFAULT_PROPERTIES = {
693+
const defaultProperties = {
694694
ARRAY: Object.getOwnPropertyNames([]).filter(intFilter),
695695
BUFFER: Object.getOwnPropertyNames(Buffer.alloc(1)).filter(intFilter)
696696
};
@@ -704,16 +704,16 @@ function filteredOwnPropertyNames(obj) {
704704
if (mayBeLargeObject(obj) && obj.length > 1e6) {
705705
this._writeToOutput('\r\n');
706706
process.emitWarning(
707-
'Instance is too large that the completion may missing ' +
708-
'some customized properties.',
707+
'Instance is too large so the completion may missing some custom ' +
708+
'properties.',
709709
'REPLWarning',
710710
undefined,
711711
undefined,
712712
true);
713713

714714
return Array.isArray(obj) ?
715-
DEFAULT_PROPERTIES.ARRAY :
716-
DEFAULT_PROPERTIES.BUFFER;
715+
defaultProperties.ARRAY :
716+
defaultProperties.BUFFER;
717717
}
718718
return Object.getOwnPropertyNames(obj).filter(intFilter);
719719
}
@@ -756,7 +756,6 @@ function complete(line, callback) {
756756
}
757757
}
758758

759-
var self = this;
760759
var completions;
761760

762761
// list of completion lists, one for each inheritance "level"
@@ -892,13 +891,13 @@ function complete(line, callback) {
892891
}
893892
} else {
894893
const evalExpr = `try { ${expr} } catch (e) {}`;
895-
this.eval(evalExpr, this.context, 'repl', function doEval(e, obj) {
894+
this.eval(evalExpr, this.context, 'repl', (e, obj) => {
896895
// if (e) console.log(e);
897896

898897
if (obj != null) {
899898
if (typeof obj === 'object' || typeof obj === 'function') {
900899
try {
901-
memberGroups.push(filteredOwnPropertyNames.call(self, obj));
900+
memberGroups.push(filteredOwnPropertyNames.call(this, obj));
902901
} catch (ex) {
903902
// Probably a Proxy object without `getOwnPropertyNames` trap.
904903
// We simply ignore it here, as we don't want to break the
@@ -916,7 +915,7 @@ function complete(line, callback) {
916915
p = obj.constructor ? obj.constructor.prototype : null;
917916
}
918917
while (p !== null) {
919-
memberGroups.push(filteredOwnPropertyNames.call(self, p));
918+
memberGroups.push(filteredOwnPropertyNames.call(this, p));
920919
p = Object.getPrototypeOf(p);
921920
// Circular refs possible? Let's guard against that.
922921
sentinel--;

test/parallel/test-repl-tab-complete.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
const common = require('../common');
2525
const assert = require('assert');
26-
const Buffer = require('buffer').Buffer;
2726

2827
// We have to change the directory to ../fixtures before requiring repl
2928
// in order to make the tests for completion of node_modules work properly
@@ -307,6 +306,8 @@ testMe.complete('.b', common.mustCall((error, data) => {
307306
}));
308307

309308
// tab completion for large buffer
309+
const warningRegEx =
310+
/\(node:\d+\) REPLWarning: Instance is too large so the completion may missing some custom properties\./;
310311
[ Array, Buffer ].forEach((type) => {
311312
putIn.run(['.clear']);
312313

@@ -317,8 +318,8 @@ testMe.complete('.b', common.mustCall((error, data) => {
317318
}
318319

319320
common.hijackStderr(common.mustCall((err) => {
320-
process.nextTick(function() {
321-
assert.ok(/REPLWarning: Instance is too large that the/.test(err));
321+
process.nextTick(() => {
322+
assert.ok(warningRegEx.test(err));
322323
});
323324
}));
324325
testMe.complete('ele.', common.mustCall((err, data) => {

0 commit comments

Comments
 (0)