Skip to content

Commit

Permalink
util: fix inspecting symbol key in string
Browse files Browse the repository at this point in the history
PR-URL: #11672
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
barinali authored and evanlucas committed Mar 7, 2017
1 parent 8402888 commit 7b84363
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ function formatValue(ctx, value, recurseTimes) {
// for boxed Strings, we have to remove the 0-n indexed entries,
// since they just noisy up the output and are redundant
keys = keys.filter(function(key) {
if (typeof key === 'symbol') {
return true;
}

return !(key >= 0 && key < raw.length);
});
}
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ assert.strictEqual(util.inspect(Object.create({},
{visible: {value: 1, enumerable: true}, hidden: {value: 2}})),
'{ visible: 1 }'
);
assert.strictEqual(util.inspect(Object.assign(new String('hello'),
{ [Symbol('foo')]: 123 }), { showHidden: true }),
'{ [String: \'hello\'] [length]: 5, [Symbol(foo)]: 123 }');

{
const regexp = /regexp/;
Expand Down

0 comments on commit 7b84363

Please sign in to comment.