News for hackers. Stuff that matters.
Re:NPM – "is-even", 160k weekly downloads by Ajedi32 on Tuesday November 16, 2021 @11:49AM (#29242779)
So in conclusion... maybe checking whether a number is even in JS isn't as trivial as everyone thought, and projects reusing that code was a good thing?

Or are are all those extra checks unnecessary now that TypeScript exists and new functions like Number.isInteger have widespread browser support?

Re:NPM – "is-even", 160k weekly downloads by mannerheim on Tuesday November 16, 2021 @12:00PM (#29242974)
If so, the implementation of isEven isn't even right because it assumes anything that isn't an odd number is an even number.
Re:NPM – "is-even", 160k weekly downloads by Ajedi32 on Tuesday November 16, 2021 @12:01PM (#29243015)
No, the code posted in this thread clearly indicates it will raise an exception in such cases.
Re:NPM – "is-even", 160k weekly downloads by mannerheim on Tuesday November 16, 2021 @12:04PM (#29243053)
Ah, that's right, never mind.
Re:NPM – "is-even", 160k weekly downloads by hmrr on Tuesday November 16, 2021 @12:45PM (#29243684)
I think the assertion (sorry for the pun) is that JavaScript is a completely unholy creation and should be chucked off the edge of the disc.

I can’t imagine trying to get some of our fintech business logic in there without arming a nuclear foot gun or ten. I would never sleep again without medication.

Re:NPM – "is-even", 160k weekly downloads by runes on Wednesday November 17, 2021 @03:31AM (#29250383)
TypeScript can't help at all, it vanishes before the code runs.