Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #26 from APSL/is_integer
Browse files Browse the repository at this point in the history
Fix isInteger(null) === true
  • Loading branch information
gcanti authored May 8, 2017
2 parents 8565ed0 + 5c6f3e6 commit d0b1858
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var t = require('tcomb');

function isInteger(n) {
return n % 1 === 0;
return typeof n === 'number' && isFinite(n) && Math.floor(n) === n;
}

var Null = t.irreducible('Null', function (x) { return x === null; });
Expand All @@ -13,4 +13,4 @@ module.exports = {
isInteger: isInteger,
Null: Null,
Int: Int
};
};

0 comments on commit d0b1858

Please sign in to comment.