News for hackers. Stuff that matters.
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by jrvxo on Wednesday June 19, 2019 @09:53AM (#20223341)
https://www.npmjs.com/package/is-odd

is-odd 831,460 weekly downloads

Re:One liner NPM package “is-windows” has 2.5M dependants, w... by knd775 on Wednesday June 19, 2019 @10:04AM (#20223438)
Even 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);
  };
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by dingaling on Wednesday June 19, 2019 @10:24AM (#20223620)
What does it return for zero?
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by rys on Wednesday June 19, 2019 @10:44AM (#20223823)
(Thankfully?) it gets that right
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by tlrobinson on Wednesday June 19, 2019 @10:34AM (#20223705)
Zero is even.
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by arcticfox on Wednesday June 19, 2019 @10:11AM (#20223501)
I 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.

Re:One liner NPM package “is-windows” has 2.5M dependants, w... by tlrobinson on Wednesday June 19, 2019 @10:42AM (#20223799)
My 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.
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by SketchySeaBeast on Wednesday June 19, 2019 @10:00AM (#20223411)
It'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.
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by tastroder on Wednesday June 19, 2019 @10:13AM (#20223523)
This 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...

Re:One liner NPM package “is-windows” has 2.5M dependants, w... by OskarS on Wednesday June 19, 2019 @10:34AM (#20223711)
Even 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....

Re:One liner NPM package “is-windows” has 2.5M dependants, w... by imtringued on Wednesday June 19, 2019 @11:04AM (#20223995)
0 is not a positive number.
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by OskarS on Wednesday June 19, 2019 @11:18AM (#20224111)
Fair enough, "non-negative integers" then.
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by daxterspeed on Wednesday June 19, 2019 @10:11AM (#20223502)
is-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.

Re:One liner NPM package “is-windows” has 2.5M dependants, w... by uranusjr on Thursday June 20, 2019 @01:17AM (#20230112)
To 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.
Re:One liner NPM package “is-windows” has 2.5M dependants, w... by _ink_ on Wednesday June 19, 2019 @10:00AM (#20223403)
This is the one I wanted to point out. At least it adds a few type checks.