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
R.aperture
, but it doesn't quite do what I need
array.reduce((acc, d, i) => {
const excluded = d => d && d.exclude === true;
if (excluded(d) || excluded(array[i - 1]) || excluded(array[i + 1])) {
return acc.concat(d);
}
else {
return acc;
}
}, [])
// given an arr of data objects, returns the field with the lowest minimum value
// i.e. which field has the lowest point on the graph: ['accumulatedDeposit', 'balance']?
export const getLowerMinimumOfFields = (data, fields) => {
let lowest = { value: Infinity, type: '' };
data.forEach((dateData) => {
fields.forEach((field) => {
if (dateData[field] < lowest.value) {
lowest.value = dateData[field];
lowest.type = field;
}
});
});
return lowest.type;
};