Skip to content

Commit

Permalink
[New] Add support for upcoming BigInt
Browse files Browse the repository at this point in the history
  • Loading branch information
emilbayes authored and ljharb committed May 2, 2018
1 parent 48cae12 commit 866c46a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions test/bigint.js
Original file line number Diff line number Diff line change
@@ -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');
});

0 comments on commit 866c46a

Please sign in to comment.