3 ms·
It’s completely stupid that this kind of module gets used in the JavaScript ecosystem, but as the author points out, it’s not his fault, it’s downstream modules
by burke 6y ago
It’s completely stupid that this kind of module gets used in the JavaScript ecosystem, but as the author points out, it’s not his fault, it’s downstream modules’ fault for actually using something so trivial.
It’s deeply unfortunate that the lack of a standard library in JavaScript combined with the constraint of wanting to minimize shipped code size in a language that resisted dead code elimination for a long time led to... whatever this is, instead of a comprehensive stdlib.
- seattle_spring 6y agoDid you read the code? It is standard functionality, but only in newer Node versions and browsers. The linked package is basically a polyfill.
- wongarsu 6y agoIt is now, but it wasn't standard functionality back when this library was first published.
- aPoCoMiLogin 6y agofirst commit is from 2013 [0], first Node that had Array.isArray was 0.1.15 from 2009 [1], thus making is as Node module was pointless, but polyfill for browsers might have some sense. - [0] https://github.com/juliangruber/isarray/commit/c8601522e31366d0ce1bfd11818c4bb3ebd032a4 https://github.com/juliangruber/isarray/commit/c8601522e3136... - [1] https://github.com/nodejs/node-v0.x-archive/blob/v0.1.15/ChangeLog https://github.com/nodejs/node-v0.x-archive/blob/v0.1.15/Cha...
- hn_throwaway_99 6y agoPeople keep saying this is "so trivial", denigrating anyone who would use this, but I am convinced they haven't even looked at the "one line of code" they are denigrating. I've been a JS/Node dev for years now (granted, post a time when Array.isArray was part of the standard), and if someone asked me to write isArray, I wouldn't have done it like this, and I'm assuming there is a reason it was done like this. What I really see is a bunch of typical "I'm a cooler dev than you" posturing for people who haven't even actually looked at the code. That's a shame because there is a valid discussion to be had around how lots of teeny dependencies can make the npm ecosystem brittle, but bullshit posturing around how any dev should be able to write this one line is just false.
- dirkt 6y agoCan't upvote this enough ...
- burke 6y agoSure, ok. I can buy that this is not actually completely trivial, and that it's worth bringing code to solve this problem in from some other source. Still, it's a shame that the specifics of the way the JavaScript ecosystem has evolved mean that it's commonplace to bring in a <10 line dependency to mitigate an extremely core lack of functionality, rather than have a first-party—or be able to sensibly import a third-party—standard library. I can't think of any other language ecosystem where this is normal.
- hn_throwaway_99 6y agoAgain, did you even read the package? This is part of the JS standard, and has been for years. This is basically just a polyfill for people that need to support very (very) old browsers.