summaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-03-14 10:03:36 +0100
committerMichaël Zasso <targos@protonmail.com>2018-03-17 11:37:53 +0100
commit893432ad928e25854950c0b5c581dfb3081ed4bb (patch)
tree76890a06b79c69297c77fb896041af7da1f1ab13 /lib/util.js
parent6a5a9ad62decfc7a5a41e362484dc0e56c648e67 (diff)
downloadandroid-node-v8-893432ad928e25854950c0b5c581dfb3081ed4bb.tar.gz
android-node-v8-893432ad928e25854950c0b5c581dfb3081ed4bb.tar.bz2
android-node-v8-893432ad928e25854950c0b5c581dfb3081ed4bb.zip
util: add boxed BigInt formatting to util.inspect
Before: > Object(7n) BigInt {} After: > Object(7n) [BigInt: 7n] PR-URL: https://github.com/nodejs/node/pull/19341 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js
index b64d103cb3..b9ad76f4ad 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -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');