Re:You-Dont-Need-Lodash-Underscore
by mcphage on Friday August 09, 2019 @03:03PM
(#20657360)
> 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:
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.