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:
Ali BARIN 2017-03-03 13:43:16 +01:00 committed by Luigi Pinca
parent 0674771f23
commit d0b93c9fef
2 changed files with 7 additions and 0 deletions

View File

@ -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);
});
}

View File

@ -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/;