4 ms·
Can we get some additions that replace the garbage one-liner `is-even`/`is-odd` npm libraries that are a scourge?
by Dirlewanger 7y ago
Can we get some additions that replace the garbage one-liner `is-even`/`is-odd` npm libraries that are a scourge?
- tomduncalf 7y agoYou mean something like x % 2 === 1? I'm a JS fan but had to admit I chuckled at the implementation of is-even: https://github.com/jonschlinkert/is-even/blob/master/index.js https://github.com/jonschlinkert/is-even/blob/master/index.j...
- soulofmischief 7y agoThat's hilarious. What's not hilarious is that, after removing the essentially useless error-checking, is-even is literally just `(n % 2) === 1`. On one hand, JS desperately needs a standard library, on the other hand, JS devs can be so infuriatingly lazy and obtuse.
- choward 7y ago> is-even is literally just `(n % 2) === 1` Pretty sure that tells you if a number is odd. I guess maybe there is a reason these libraries exist.
- soulofmischief 7y agoThat was just a typo, I meant the source for is-odd. I copy-pasted it. I use that exact syntax all the time in code, you don't need to be patronizing.