3 ms·
npm i is-even const isEven = require("is-even"); console.log(isEven(Infinity)); TypeError: is-odd expects a number.
by paulddraper 4y ago
npm i is-even
const isEven = require("is-even");
console.log(isEven(Infinity));
TypeError: is-odd expects a number.
- Bilal_io 4y agoI read the title and I sarcastically thought "ask JavaScript!" Your comment didn't disappoint. Importing the is-even package is the cherry on top.
- paulddraper 4y agoThe amazing thing is that the is-even package depends on the is-odd package. I would have thought the reverse, but ¯\_(ツ)_/¯
- sltkr 4y agoEven with plain Javascript, `Infinity % 2` evaluates to `NaN`, as it should. And if you implement, e.g.: function IsEven(x) { return x % 2 == 0; } function IsOdd(x) { return x % 2 == 1; } Then IsEven(Infinity) == false and IsOdd(Infinity) == false, as expected.
- dist-epoch 4y agoNice find. I will file an issue, this is a very used package, it's important for it to be accurate.