Browse Source

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>
v6
Ali BARIN 8 years ago
committed by Luigi Pinca
parent
commit
d0b93c9fef
  1. 4
      lib/util.js
  2. 3
      test/parallel/test-util-inspect.js

4
lib/util.js

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

3
test/parallel/test-util-inspect.js

@ -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…
Cancel
Save