Using rest/spread we ca simplify some examples even more
const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
const over = (...fns) => (...args) => fns.map(fn => fn( ...args));
Number functions converts boolean to 1 or 0, however it would work if undefined is used as a negative ...
const bifurcateBy = (arr, fn) =>
arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]);
const bifurcateBy = (arr, fn) =>
arr.reduce((acc, val, i) => (acc[Number(fn(val, i))].push(val), acc), [[], []]);
[].flat (Bonus: it respects Symbol.species)
const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));
const deepFlatten = arr => arr.flat(Infinity);
// also flatten
objectFromPairs --> Object.fromEntries
objectToPairs --> Object.entries
We've discussed a few of these. As it stand we need to implement them. If you'd like to open a PR modifying or updating a snippet, feel free to
@GrosSacASac would you like to update these or want us from 30 core team to do it by ourselves?
Looks like a straightforward process by following our contributing docs.
it is easier if you do it
Alright. We'll do it. Thanks for mentioning it! 馃憤
Closing due to inactivity. objectToPairs is discussed under #947, objectFromPairs will be implemented in a similar fashion under the same issue and PRs.
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
We've discussed a few of these. As it stand we need to implement them. If you'd like to open a PR modifying or updating a snippet, feel free to