Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,13 @@ function formatValue(ctx, value, recurseTimes, ln) {
if (keyLength === 0)
return ctx.stylize(`[Boolean: ${formatted}]`, 'boolean');
base = `[Boolean: ${formatted}]`;
// eslint-disable-next-line valid-typeof
} else if (typeof raw === 'bigint') {
// Make boxed primitive BigInts look like such
const formatted = formatPrimitive(stylizeNoColor, raw);
if (keyLength === 0)
return ctx.stylize(`[BigInt: ${formatted}]`, 'bigint');
base = `[BigInt: ${formatted}]`;
} else if (typeof raw === 'symbol') {
const formatted = formatPrimitive(stylizeNoColor, raw);
return ctx.stylize(`[Symbol: ${formatted}]`, 'symbol');
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-util-inspect-bigint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ const assert = require('assert');
const { inspect } = require('util');

assert.strictEqual(inspect(1n), '1n');
assert.strictEqual(inspect(Object(-1n)), '[BigInt: -1n]');
assert.strictEqual(inspect(Object(13n)), '[BigInt: 13n]');