4 ms·
What about using "trustable" dependencies? For small utilities like left pad, you could use lodash. You can import just the function, but still get the benefit
by sotojuan 11y ago
What about using "trustable" dependencies? For small utilities like left pad, you could use lodash. You can import just the function, but still get the benefit of knowing that its lodash so it won't go down, it'll be fast, and well tested.
- AgentME 11y agoLeft-pad was a trustable, fast, well-tested package too, up until NPM let it disappear.
- esailija 11y agoHow is it fast? (obviously it was not trustable or well-tested) It is the slowest possible way to implement string padding without any optimization effort whatsoever. This is what I hate about npm, every module claims to be fast even though they have made no effort to be fast.
- goldbrick 11y agoIt's fast 'cus it uses libuv, duh!
- PeCaN 11y agoThis is what a lot of non-JavaScript languages do. I suspect JavaScript ended up this way because people wanted to avoid downloading anything they absolutely didn't need in the browser. Now packagers can automatically remove unused functions (WebPack 2 does this IIRC, and I think require.js did ages ago) so it's no longer a concern but somehow NPM still ended up with a million tiny libraries. Thank god Underscore/lodash didn't use the approach of one-module-per-function.
- Macha 11y agoone-module-per-function is exactly the approach Lodash uses and the Lodash devs tout is as a big advantage over underscore. The difference is they also provide the rollup bundle with all of Lodash. Which is what most users actually use.
- sotojuan 11y agoYep, that's what I meant. It's one module per function (so I can just grab what I want), but it's all part of a big project under a good maintainer, so it's trustable.
- mikeryan 11y agoThis only "kind of" works for dependencies which you explicitly include in your project. My understanding of the left-pad issue was that it was frequently down the dependency tree where dev's themselves could not remove the dependency on left-pad without modifying or branching a dependency (or perhaps multiple).