> people should prefer using standard / built-in functions
I get that, but that's not what this list is: this list is re-implementing lodash / underscore using built-in functions. They're not a 1-for-1 replacement, they're complex implementations which may or may not be correct or efficient. If their solution for replacing _.chunk(...) was some built-in Array.chunk(...) or something, that would be fine. But instead, it's this:
> const chunk = (input, size) => {
> return input.reduce((arr, item, idx) => {
> return idx % size === 0
> ? [...arr, [item]]
> : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]];
> }, []);
> };
That's definitely worse than using lodash.
Re:You-Dont-Need-Lodash-Underscore
by tlrobinson on Friday August 09, 2019 @03:39PM
(#20657642)
That's exactly what I said in my second paragraph...
However, I don't necessarily agree with this approach of providing snippets for functions which aren't implemented natively. Underscore and Lodash likely have better implementations and much more testing. If you're concerned about bundle size, use tree shaking or individual function imports.
I think one exception to this is if you are writing a library and want to keep dependencies to an absolute minimum.