## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Jan 31 2019 22:17
CrossEye commented #2779
• Jan 31 2019 21:04
ArturAralin commented #2779
• Jan 31 2019 20:08
CrossEye commented #2779
• Jan 31 2019 18:56
buzzdecafe commented #2631
• Jan 31 2019 18:09
ArturAralin commented #2779
• Jan 31 2019 16:18
CrossEye commented #2779
• Jan 31 2019 16:10
CrossEye commented #2631
• Jan 31 2019 16:06
CrossEye commented #2777
• Jan 31 2019 14:44
ArturAralin opened #2779
• Jan 31 2019 07:39
inferusvv commented #2631
• Jan 31 2019 03:07
sespinozj commented #2771
• Jan 31 2019 02:33
• Jan 31 2019 02:26
JeffreyChan commented #2777
• Jan 30 2019 14:30
CrossEye closed #2777
• Jan 30 2019 12:13
• Jan 30 2019 01:42
JeffreyChan commented #2777
• Jan 29 2019 21:06
• Jan 29 2019 16:28
CrossEye commented #2777
• Jan 29 2019 15:50
mbostock commented #2772
• Jan 29 2019 15:48
CrossEye commented #2772
Ben Briggs
@ben-eb
@Twizzes Untested but could be shortened :)
const includedIn = flip(includes);

const res = filter(propSatisfies(includedIn(ids), 'uniqueId')) (recipes)
Kevin Thompson
@kthompson
im trying to make a method to convert a list into a map by id with rambda, i have the follow following but its not working as expected:
const assignById = converge(call, [
flip(assoc),
prop('id')
]);

assignById({id: 'abc', taco: 'time'}, {}) // => {abc: {id: 'abc', taco: 'time'} }
Kevin Thompson
@kthompson
i think this will work for now
const toMap = R.pipe(
R.groupBy(R.prop('id')),
)
converge sets its arity based on the highest arity of the branch functions
Kevin Thompson
@kthompson
yea i was reading that but still couldnt really figure it out
Since assoc has an arity of 3 it will take all 3 arguments before passing the results to call
if you need to partially apply a function in converge you can either do it manually (x) => flip(assoc)(x) or use a helper function like arity
Kevin Thompson
@kthompson
i dont see arity but thanks for the info
Sorry, it's called nAry
arity seems like a more reasonable name lol
Kevin Thompson
@kthompson
Yea. That gives me something like
const toMap2 = R.reduce(
R.flip(
R.uncurryN(
2,
R.converge(R.call, [
x => R.flip(R.assoc)(x),
R.prop('id')
])
)
),
{}
);
i think the other implementation is a bit more clear/concise though
Twizzes
@Twizzes
@kthompson can you use Object.entries?
Kevin Thompson
@kthompson
i'm taking an array of objects and turning it into a map with the object's id as the key.
const toMap = R.pipe(
R.groupBy(R.prop('id')),
)
is the simplest way i can come up with

i think the other implementation is a bit more clear/concise though

:+1:

Kevin Thompson
@kthompson
Oh, I just found this...
const toMap3 = R.indexBy(R.prop('id'));
mitcho
gotta love that progression haha
Gezim Hoxha
Why does the object in filter (second param) have to have an index type of 'string'?
Lewis
@6ewis
hi
do you have a cleaner alternative
Lewis
@6ewis
const showColumns= (visibleColumns)  =>
const indexOfVisibleColumn = visibleColumns.map(col => col.name).indexOf(header.name);
if ( indexOfVisibleColumn !== -1) {
const { title } = visibleColumns[indexOfVisibleColumn]
title  ?
};

console.log("how does acc look like", acc);
return acc;
}, []);
;
Twizzes
@Twizzes
@6ewis
const visibleNames = R.map(R.prop('name'))

headers.filter(header => R.includes(R.prop('name')(header), visibleNames(visibleColumns)))
Julien
@customcommander
Is it right/appropriate to have this ramda-adjunct package “advertised" so many times in the Ramda Cookbook? I was tempted to raise a PR to remove this but wanted to check first. Personally I don’t think it is; it causes confusion more than anything.
Julien
@customcommander

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.

Oscar Bolmsten
@oscar-b
Any @types maintainer here? Either I'm daft or there's missing type for takeLastWhile when used with a string.
Daniel Cheung
@danvim
I just added "rambda": "^4.4.0" to my project. From the docs, I see that it supposedly has the invert and invertObj functions. However, I can't find them in the dist. When I open up src under the node_module, I do see invert and invertObj in their respective files though.
Anyone knows what has happened to them?
Syaiful Bahri
@syaiful6
@danvim i guess it's typo problem, it's ramda not rambda
John Hartnup
@ukslim
rambda is a "faster alternative to Ramda" -- but I don't see anything about invert in its docs: https://selfrefactor.github.io/rambda/#/
I do see invert in Rambda docs's list of "Ramda methods missing in Rambda" - https://github.com/selfrefactor/rambda/blob/master/files/ramdaMissing.md
John Hartnup
@ukslim
Interesting - Rambda's authors say they see the fewer methods as an advantage, and it looks as if they feel the methods they've chosen to omit are ones you're likely not to need. But I see tons of functions that my team uses a lot. converge, applySpec, cond, unless, when ...
Daniel Cheung
@danvim
Thanks, that's interesting. It's my first time using ramda. I used to use lodash. Thought it made sense if the name would contain a 'b', but it didn't.
John Hartnup
@ukslim
Since I've broken my Gitter silence: a plug for the library I recently published - https://www.npmjs.com/package/ramda-decimal#ramda-decimal
Feedback very welcome.
kapilpipaliya
@kapilpipaliya
thanks for ramda
Lewis
@6ewis
R.isNil(a) || R.isNil(b)
Oskar Grunning
@sQVe
What would be the best way to write a signature for a object {k: v} but with a specfic design? It has the name Container in my TypeScript code but I'm a bit unsure how I should write the Hindley Milner signature.
combineContainers :: {k: v} -> {k: v} -> {k: v} seems a bit too generic - or am I wrong?
@6ewis any(isNil, [a, b])?
@sQVe is Container like a specific record type, or is it more like a typeclass?
Norbert
@norbertpy
Folks, what stops the 0.27.0 version to be published?
John Hartnup
@ukslim
@6ewis Why do you feel 'shortest' is a useful aim? And why mix Ramda and non-Ramda styles? or(isNil(a), isNil(b))
Mike Lambert
@lambert-velir
hey guys! I had a problem the other day, I needed to include all elements that had the field excluded set to true, but also all the elements that are before for after one that has excluded true
here's some sample data:
[
{
id: 1
},
{
id: 2
},
{
id: 3,
excluded: true
},
{
id: 4,
excluded: true
},
{
id: 5
},
{
id: 6
}
];
so the results should be 2, 3, 4, 5
I ended up using a regular [].reduce because I had an index, and could look at i -1 and i + 1
I was thinking about using R.aperture, but it doesn't quite do what I need
essentially, I need a filter that can look at the elements next to it
here's my solution:
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;
}
}, [])