const recipes = [{ uniqueId: 5 }, { uniqueId: 2 }, { uniqueId: 10 }];
const ids = [2, 5, 6, 1];
const _includes = keepers => item => R.includes(item, keepers);
const keepIds = _includes(ids);
const res = recipes.filter(R.compose(keepIds, R.prop("uniqueId")));
console.log(JSON.stringify(res));
// => [{"uniqueId":5},{"uniqueId":2}]
const assignById = converge(call, [
flip(assoc),
prop('id')
]);
assignById({id: 'abc', taco: 'time'}, {}) // => {abc: {id: 'abc', taco: 'time'} }
converge
you can either do it manually (x) => flip(assoc)(x)
or use a helper function like arity
arity
seems like a more reasonable name lol
const toMap = R.pipe(
R.groupBy(R.prop('id')),
R.map(R.head)
)
is the simplest way i can come up with
const showColumns= (visibleColumns) =>
headers.reduce((acc, header) => {
const indexOfVisibleColumn = visibleColumns.map(col => col.name).indexOf(header.name);
if ( indexOfVisibleColumn !== -1) {
const { title } = visibleColumns[indexOfVisibleColumn]
title ?
acc.push({ ...header, title }) :
acc.push({ ...header })
};
console.log("how does acc look like", acc);
return acc;
}, []);
;
I mean isn’t a link in “Related projects” enough?
https://github.com/ramda/ramda/wiki#related-projects
If other projects were doing the same thing, the Cookbook could become a messy place IMHO.
invert
in its docs: https://selfrefactor.github.io/rambda/#/
invert
in Rambda docs's list of "Ramda methods missing in Rambda" - https://github.com/selfrefactor/rambda/blob/master/files/ramdaMissing.md
Container
like a specific record type, or is it more like a typeclass?
[
{
id: 1
},
{
id: 2
},
{
id: 3,
excluded: true
},
{
id: 4,
excluded: true
},
{
id: 5
},
{
id: 6
}
];
[].reduce
because I had an index, and could look at i -1
and i + 1