Skip to content

Commit 1ac548e

Browse files
emilbayesljharb
authored andcommitted
[New] Add support for upcoming BigInt
1 parent ff9eff6 commit 1ac548e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
3838
}
3939
return String(obj);
4040
}
41+
if (typeof obj === 'bigint') {
42+
return String(obj) + 'n';
43+
}
4144

4245
var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
4346
if (typeof depth === 'undefined') depth = 0;

test/bigint.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var inspect = require('../');
2+
var test = require('tape');
3+
4+
test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) {
5+
t.plan(3);
6+
7+
t.equal(inspect(BigInt(-256)), '-256n');
8+
t.equal(inspect(BigInt(0)), '0n');
9+
t.equal(inspect(BigInt(256)), '256n');
10+
});

0 commit comments

Comments
 (0)