Hacker News new | ask | show | jobs
by tokenizerrr 2947 days ago
All of these packages are created by Jon Schlinkert (https://github.com/jonschlinkert). So if you want someone to blame...
1 comments

https://github.com/jonschlinkert/is-odd/blob/master/index.js

Edit:

the original code, even before the float handling, was was a perf optimisation:

    !!(~~i & 1);
Nobody wants to see that in code unless it has a name. Maybe isOdd(). Maybe we should put it on GitHub to save others time. Sure beats copy-pasting from StackOverflow.

Original:

Did you think of handling floats in your home built isOdd implementation? Thankfully Jon (EDIT: or one of his contributors - doesn't change the point) did. And they added tests.

The (flagged) article makes the staggering assumption that "we can't code" because we're not constantly reinventing the wheel. It talks about DRY being taken too far and talks about the functions being replaced as "one liners", when following a couple of links would show they're not. We can code, we're just coding on actual features, not rewriting the same poop.

Isn't this evidence that the system is working?

Because it's a package, a bug/oversight was found, and it was made more robust.

I still wouldn't personally use `is-odd`, but isn't this proof that having something even this trivial as a package can have benefits?

I find it interesting that the author added an `isInteger` dependency then went on to not use it.
I'd say there are very few circumstances where you want to know if a number is odd but could plausibly have floats as an input.