I've noticed some snippets come in recently that start
const fn = (...arr) => arr = [].concat(...arr), ...
which is a combination of the variadic adapter and a piped flatten before the function.
Should we allow these? While a cool trick, it also leads to a lot of code duplication in snippets.
It's also a situation where
const fn = pipe(fn, flatten, collectInto)
should do the same thing and allow us to keep snippets smaller, less duplicated, and not have every snippet have a confusing footprint of (*|Array<*>|...*) and instead just be one of the three
Now don't get me wrong, the contributions have been great, I'm just curious if we want to duplicate flatten in those snippets or just make them variadic to match with Math.?
Well, turns out that was a pretty bad decision. Your last comment under #295 proves this can go very wrong very fast. Yes, we want developers to handle their own errors and bad input, but this is a bit too far. Keeping everything variadic, without accounting for arrays (not using .concat()) should be ok, provided we add examples that use arrays in combination with the spread operator.
@Chalarangelo In that case, does that make max/min pointless? Since they will no longer accept array inputs
max/min are shim methods that would pipe the input to the Math library for max and min. With adapters those examples are pointless since
const arrayMax = spreadOver(Math.max)
const arrayMin = spreadOver(Math.min)
We could probably change the examples for spreadOver and collectInto to make it a little more clear how it can be used in some situations(promise.all results are awesome for this)
Tomorrow after work( around 18:00:00 PST ) I'll PR the removal of Math.max and Math.min unless someone beats me to it and resolves this issue. I've been away for the holiday
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for any follow-up tasks.
Most helpful comment
Tomorrow after work( around 18:00:00 PST ) I'll PR the removal of Math.max and Math.min unless someone beats me to it and resolves this issue. I've been away for the holiday