From 5c6f3e64a637abbc7b52ceaad931e7e827f4dc1e Mon Sep 17 00:00:00 2001 From: Daniel Sastre Date: Mon, 8 May 2017 17:14:39 +0200 Subject: [PATCH] Fix isInteger(null) === true Polyfill from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger. --- util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util.js b/util.js index 8a05b06..d65b5a0 100644 --- a/util.js +++ b/util.js @@ -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; }); @@ -13,4 +13,4 @@ module.exports = { isInteger: isInteger, Null: Null, Int: Int -}; \ No newline at end of file +};