These are chat archives for ramda/ramda

3rd
Jan 2018
Henrik Raitasola
@henrikra
Jan 03 2018 07:05
const people = [
  {name: 'John', age: 25},
  // ...
];

const initializedPeople = people.map(person => ({
  ...person,
  isEnabled: true,
  isVisible: true,
}));
is there function in ramda that can do the same inside my mapfunction? :D
so basically people is array I get from api
then I want to put them to my React state but I would like to initialize some values to person objects too before putting them in state
Pygmalion
@PygmalionPolymorph
Jan 03 2018 08:10
Maybe you can do something like this:
const initialize = compose(assoc('isEnabled', true), assoc('isVisible', true));
people.map(initialize)
Lucas Schejtman
@lucasschejtman
Jan 03 2018 08:19
or like this
const initializedPeople  = R.merge({
  isEnabled: true,
  isVisible: true
});

R.map(initializedPeople , people)
Henrik Raitasola
@henrikra
Jan 03 2018 09:22
wow nice! Thanks for these tips :+1:
Henrik Raitasola
@henrikra
Jan 03 2018 11:31
Are you guys using ramda with typescript?
Francisco
@franciscotln
Jan 03 2018 14:46
I used to, imo it's not worth it, specially when piping funcs.
Henrik Raitasola
@henrikra
Jan 03 2018 15:24
or really? :O
can you give an example when you found it not useful/annoying
Jonas Windey
@jonaswindey
Jan 03 2018 17:05
hi guys, if I have a piped function that takes one arg, how can I transform it to take 2 args and execute it with fn(a, b) and have it exucuted like fn(a)(b) ?
I'd like to call the function directly without const sortAndFilterInquiries = (search, inquiries) => sortAndFilter(search)(inquiries)
Brad Compton (he/him)
@Bradcomp
Jan 03 2018 17:14
You could use
R.uncurry
ram-bot
@ram-bot
Jan 03 2018 17:14
Error: No such function uncurry
Brad Compton (he/him)
@Bradcomp
Jan 03 2018 17:14
R.uncurryN
Jonas Windey
@jonaswindey
Jan 03 2018 17:16
thanks, was searching for reverse/inverse curry
Brad Compton (he/him)
@Bradcomp
Jan 03 2018 17:26
:bowtie:
Wesley Schleumer de Góes
@schleumer
Jan 03 2018 22:56
Guys, how do i write memoizeWith on Typescript? I've installed @types/ramda but memoizeWith still not there :(
Brad Compton (he/him)
@Bradcomp
Jan 03 2018 23:02
R.memoizeWith
Brad Compton (he/him)
@Bradcomp
Jan 03 2018 23:03
I'm not too familiar with Typescript, can you encode a type signature like that?
Wesley Schleumer de Góes
@schleumer
Jan 03 2018 23:17
I found my problem, it was the editor :confused: Webstorm was loading Typescript's type definitions incorrectly, then i opened into VsCode and everything was nice