Skip to content

Commit

Permalink
supports -0
Browse files Browse the repository at this point in the history
  • Loading branch information
brigand committed Oct 31, 2016
1 parent 212ee7b commit e892727
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
if (typeof obj === 'string') {
return inspectString(obj);
}
if (typeof obj === 'number') {
if (Object.is) {
if (Object.is(obj, -0)) {
return '-0';
}
}
return String(obj);
}
else if (typeof obj === 'function') {
var name = nameOf(obj);
return '[Function' + (name ? ': ' + name : '') + ']';
Expand Down
8 changes: 8 additions & 0 deletions test/number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var inspect = require('../');
var test = require('tape');

test('negative zero', function (t) {
t.equal(inspect(0), '0');
t.equal(inspect(-0), '-0');
t.end();
});

0 comments on commit e892727

Please sign in to comment.