3 ms·
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 h
by TehShrike 4y ago
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 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 https://github.com/angus-c/just
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- phailhaus 4y agoDo 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.
- TehShrike 4y agoThe 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.
- phailhaus 4y agoThe 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.
- antifa 4y ago> 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.