util: fix inspecting symbol key in string
PR-URL: https://github.com/nodejs/node/pull/11672 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
0674771f23
commit
d0b93c9fef
@ -361,6 +361,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);
|
||||
});
|
||||
}
|
||||
|
@ -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/;
|
||||
|
Loading…
x
Reference in New Issue
Block a user