Skip to content
Closed
Show file tree
Hide file tree
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
fixup
  • Loading branch information
BridgeAR committed Jul 26, 2017
commit ab497dfd4b7104c28e632ccd620121d01fa6755d
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
break;
const i = +elem;
if (index !== i) {
if (i !== i) // Fast NaN check
if (i > 0 === false)
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 add a comment on why this is necessary, and different from i <= 0? (I understand it because I saw an earlier version of the PR, but comments are more for future than now anyway.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added

continue;
const emptyItems = i - index;
const ending = emptyItems > 1 ? 's' : '';
Expand Down
10 changes: 9 additions & 1 deletion test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,16 @@ assert.strictEqual(
get: function() { this.push(true); return this.length; }
}
);
Object.defineProperty(
value,
'-1',
{
enumerable: true,
value: -1
}
);
assert.strictEqual(util.inspect(value),
'[ 1, 2, 3, growingLength: [Getter] ]');
'[ 1, 2, 3, growingLength: [Getter], \'-1\': -1 ]');
}

// Function with properties
Expand Down