Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0858e62

Browse filesBrowse files
addaleaxevanlucas
authored andcommitted
util: inspect boxed symbols like other primitives
Inspect boxed symbol objects in the same way other boxed primitives are inspected. Fixes: #7639 PR-URL: #7641 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 939cf6d commit 0858e62
Copy full SHA for 0858e62

File tree

Expand file treeCollapse file tree

2 files changed

+5
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-0
lines changed
Open diff view settings
Collapse file

‎lib/util.js‎

Copy file name to clipboardExpand all lines: lib/util.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ function formatValue(ctx, value, recurseTimes) {
413413
formatted = formatPrimitiveNoColor(ctx, raw);
414414
return ctx.stylize('[String: ' + formatted + ']', 'string');
415415
}
416+
if (typeof raw === 'symbol') {
417+
formatted = formatPrimitiveNoColor(ctx, raw);
418+
return ctx.stylize('[Symbol: ' + formatted + ']', 'symbol');
419+
}
416420
if (typeof raw === 'number') {
417421
formatted = formatPrimitiveNoColor(ctx, raw);
418422
return ctx.stylize('[Number: ' + formatted + ']', 'number');
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ test_lines({
474474

475475
// test boxed primitives output the correct values
476476
assert.equal(util.inspect(new String('test')), '[String: \'test\']');
477+
assert.equal(util.inspect(Object(Symbol('test'))), '[Symbol: Symbol(test)]');
477478
assert.equal(util.inspect(new Boolean(false)), '[Boolean: false]');
478479
assert.equal(util.inspect(new Boolean(true)), '[Boolean: true]');
479480
assert.equal(util.inspect(new Number(0)), '[Number: 0]');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.