4 ms·
https://www.npmjs.com/package/is-odd https://www.npmjs.com/package/is-odd is-odd 831,460 weekly downloads
by jrvxo 7y ago
https://www.npmjs.com/package/is-odd https://www.npmjs.com/package/is-odd
is-odd 831,460 weekly downloads
- _ink_ 7y agoThis is the one I wanted to point out. At least it adds a few type checks.
- SketchySeaBeast 7y agoIt's very easy to flippantly go "why would you ever use that???", but I'm honestly wondering what is the actual justification for the use of such a package. I see it does some initial checking (which will take more lines in your own code to deal with), but I can't figure out why someone would actually use that.
- daxterspeed 7y agois-odd's behavior is also extremely odd. It depends on "is-number" (why would this need a dependency to begin with?), which checks in the most bizarre way imaginable if the input number or string(??) is finite. is-number, and by extension is-odd, also doesn't support BigInts. These projects seem to have been created and promoted just to boost the author's "npm score" / package count. These micro-modules must cause more problems than they solve.
- uranusjr 7y agoTo be fair, it is actually far from trivial to determine whether a value is a numeric value in JavaScript, and most all-in-one utility libraries (jQuery, Lodash, etc.) java something of similar functionality. If there is one function that needs its own NPM entry, this probably is.
- tastroder 7y agoThis one year old reddit discussion [1] seems to indicate that the package was used in another, pretty popular and more complex, package by the same author. The dependency doesn't look current anymore but it might be downloads of previous versions. As for justification and usage I couldn't tell you, apparently it was only used once in that whole codebase anyway (also according to that thread). [1] https://www.reddit.com/r/programming/comments/886zji/why_has_there_been_nearly_3_million_installs_of/ https://www.reddit.com/r/programming/comments/886zji/why_has...
- OskarS 7y agoEven worse: it is only used one time in the entire code-base, and that one time was to check whether or not a value returned by the string length function was odd. What.... why.... the only concievable point of a package like this is that at least it does the kind of type-checking needed to compensate for JavaScripts weak typing system, but why do you need to check the type of String.length?! Do you really think it's going to start spitting anything other than a positive integer? Fucking hell....
- imtringued 7y ago0 is not a positive number.
- OskarS 7y agoFair enough, "non-negative integers" then.
- knd775 7y agoEven better is 'is-even'. It depends on 'is-odd' and this is the entire thing: var isOdd = require('is-odd'); module.exports = function isEven(i) { return !isOdd(i); };
- dingaling 7y agoWhat does it return for zero?
- tlrobinson 7y agoZero is even.
- rys 7y ago(Thankfully?) it gets that right
- arcticfox 7y agoI don't know if it's happening here, but I suspect this has happened before: 1) write actually useful package, get 10k weekly downloads 2) split out 100 utility functions and use them as dependencies 3) magic - your packages now have ~1M weekly downloads. You are now a JS superstar.
- tlrobinson 7y agoMy problem with these kinds of libraries is it’s not at all obvious how it behaves in edge cases, and they’re so simple I’d rather just implement it myself. Maybe I want it to throw an error, maybe I just want it to return false. Even the documentation doesn’t tell you what happens for non-integer values, you have to look at the source, at which point you may as well copy it into your own source tree.