diff --git a/index.js b/index.js index ae78858..7adbe04 100644 --- a/index.js +++ b/index.js @@ -38,6 +38,9 @@ module.exports = function inspect_ (obj, opts, depth, seen) { } return String(obj); } + if (typeof obj === 'bigint') { + return String(obj) + 'n'; + } var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth; if (typeof depth === 'undefined') depth = 0; diff --git a/test/bigint.js b/test/bigint.js new file mode 100644 index 0000000..2e3a144 --- /dev/null +++ b/test/bigint.js @@ -0,0 +1,10 @@ +var inspect = require('../'); +var test = require('tape'); + +test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) { + t.plan(3); + + t.equal(inspect(BigInt(-256)), '-256n'); + t.equal(inspect(BigInt(0)), '0n'); + t.equal(inspect(BigInt(256)), '256n'); +});