Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use this._writeToOutput to instead of process.stdout.write
  • Loading branch information
XadillaX committed Jun 20, 2017
commit 59649f38418c9e6cfcefca8abea0acb8d93ce9b0
13 changes: 8 additions & 5 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ function mayBeLargeObject(obj) {
function filteredOwnPropertyNames(obj) {
if (!obj) return [];
if (mayBeLargeObject(obj) && obj.length > 1e6) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a constant for 1e6 like const ARRAY_LENGTH_THRESHOLD?

process.stdout.write('\r\n');
this._writeToOutput('\r\n');
process.emitWarning(
'Instance is too large that the completion may missing ' +
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like "so" might be better than "that" here (but I'm not a native speaker).

'some customized properties.',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And "custom" might be better than "customized" here. (As for me, "customized" implies properties that have been changed, not necessarily added.)

Expand Down Expand Up @@ -756,6 +756,7 @@ function complete(line, callback) {
}
}

var self = this;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would prefer not to introduce a new var self = this into this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I need use this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use an arrow function so that you don't need the var self = this trick?

var completions;

// list of completion lists, one for each inheritance "level"
Expand Down Expand Up @@ -867,9 +868,11 @@ function complete(line, callback) {
if (this.useGlobal || vm.isContext(this.context)) {
var contextProto = this.context;
while (contextProto = Object.getPrototypeOf(contextProto)) {
completionGroups.push(filteredOwnPropertyNames(contextProto));
completionGroups.push(
filteredOwnPropertyNames.call(this, contextProto));
}
completionGroups.push(filteredOwnPropertyNames(this.context));
completionGroups.push(
filteredOwnPropertyNames.call(this, this.context));
addStandardGlobals(completionGroups, filter);
completionGroupsLoaded();
} else {
Expand All @@ -895,7 +898,7 @@ function complete(line, callback) {
if (obj != null) {
if (typeof obj === 'object' || typeof obj === 'function') {
try {
memberGroups.push(filteredOwnPropertyNames(obj));
memberGroups.push(filteredOwnPropertyNames.call(self, obj));
} catch (ex) {
// Probably a Proxy object without `getOwnPropertyNames` trap.
// We simply ignore it here, as we don't want to break the
Expand All @@ -913,7 +916,7 @@ function complete(line, callback) {
p = obj.constructor ? obj.constructor.prototype : null;
}
while (p !== null) {
memberGroups.push(filteredOwnPropertyNames(p));
memberGroups.push(filteredOwnPropertyNames.call(self, p));
p = Object.getPrototypeOf(p);
// Circular refs possible? Let's guard against that.
sentinel--;
Expand Down