From f51f5f8b7ccc85cf6acac0317b297eb2e3660b38 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Fri, 3 Mar 2017 13:43:16 +0100 Subject: [PATCH 1/3] util: fix inspecting symbol key in string --- lib/util.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/util.js b/lib/util.js index 6453727ad843b0..1ee96c1c84be11 100644 --- a/lib/util.js +++ b/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); }); } From 2eb47ab2a08cd2ce1527efafefda4a95b249670c Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Fri, 3 Mar 2017 14:54:05 +0100 Subject: [PATCH 2/3] util: add test case about inspecting symbols in string --- test/parallel/test-util-inspect.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 53f7e3014b389e..74b97bfed28166 100644 --- a/test/parallel/test-util-inspect.js +++ b/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/; From 41e92764a6efe077eb5f2fad53909229454208b5 Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Mon, 6 Mar 2017 15:45:51 +0100 Subject: [PATCH 3/3] util: fix linter errors --- test/parallel/test-util-inspect.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 74b97bfed28166..ded4e4a47f71d5 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -51,8 +51,8 @@ assert.strictEqual(util.inspect(Object.create({}, '{ visible: 1 }' ); assert.strictEqual(util.inspect(Object.assign(new String('hello'), - { [Symbol('foo')]: 123 }), { showHidden: true }), - '{ [String: \'hello\'] [length]: 5, [Symbol(foo)]: 123 }') + { [Symbol('foo')]: 123 }), { showHidden: true }), + '{ [String: \'hello\'] [length]: 5, [Symbol(foo)]: 123 }'); { const regexp = /regexp/;