3 ms·
NPM package is-odd installed almost 3M times this week
- niutech 9y agoA lot of modern JS developers must be very lazy if they need modules for such things like is-even, is-odd, is-number, etc.
- wakeywakeywakey 9y agoAn issue with these micro-packages is they introduce new semantics to your code, like throwing exceptions when vanilla JS would return NaN, etc. Once your code base grows, refactoring away from such packages is actually a lot more risky than it appears, and they tend to be sprinkled everywhere. I've found it better to write my own "utils.js" functions, with clearly-defined semantics, that become part of the project strategy. This also has the benefit of reducing dependency churn and maintenance of package.json.
- krapp 9y agoWhy isn't there a single "jmath" module that provides everything? Why a library for a single function to test for oddness that depends on a completely separate package for a single function to determine if something is a number? What is the point of the javascript universe's almost pathological degree of granularity? It can't merely be about bandwidth or latency, since combining these into a single module would probably reduce redundant code (and LOC in total) and the number of requests made to just 1.
- niutech 9y agoThere are many: - Math.js: http://mathjs.org http://mathjs.org - Numbers.js: https://numbers.github.io https://numbers.github.io - Numeric JavaScript: http://www.numericjs.com http://www.numericjs.com But the thing is, they are not suitable for such simple things like number % 2.