Hacker News new | past | comments | ask | show | jobs | submit login

Tree-shaking doesn't help much when the tree-shaken implementation is so bloated.

Here's the one you referenced, lodash.chunk: https://unpkg.com/lodash.chunk – 140 lines after removing comments and whitespace.

That's pretty small compared to a lot of the lodash utilities. Try spot-checking a few on unpkg.

I prefer angus's `just` utilities: https://github.com/angus-c/just




Do you have any examples that show that `just` is more efficient than lodash? It doesn't even have a `chunk` implementation, so it's hard to say that it's better.

The "bloat" is the result of being battle tested. A slimmer implementation would cut out edge cases that I may or may not run into. If I use Lodash, I know I'm all set.


> The "bloat" is the result of being battle tested.

Not always. Lodash's _.find is 5k. Why is something as simple as find so huge? It has a lot of magic. A lot of that magic provides safety though.

I don't recommend dropping lodash unless you can start using typescript.


The point of the OP is that you don't need dedicated functions for most of these utilities, let alone hundreds of lines of code.

0 lines of code is preferable to battle-tested code.

10 lines of code is preferable to 1000 if you don't need them.


The point of the OP was that _.chunk is 140 lines, which is apparently too much. But `just` doesn't even support chunk(), so it's unclear what the advantage is. Sure, you can theoretically spend your time crafting your own implementation, but why? For the self-satisfaction? I'd rather just get on with my work.


I would probably just copy the implementation from lodash or stackoverflow and fix it up.


A chunk replacement is only 6 lines according to:

https://youmightnotneed.com/lodash#chunk




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: