These are chat archives for ramda/ramda

29th
Nov 2017
richdouglasevans
@richdouglasevans
Nov 29 2017 13:09

Is there a Ramda function that does this?

const get = o => k => o[k]

https://lodash.com/docs/4.17.4#get

Bernat Jufré Martínez
@bjufre
Nov 29 2017 13:33
You could do something like: const get = R.flip(R.prop)
Bernat Jufré Martínez
@bjufre
Nov 29 2017 13:38
@richdouglasevans and so you could use it like this:
const get = R.flip(R.prop);
const obj = { x: ‘hello’, y: ‘there’};

get(obj, ‘x’); // “yeah”

const getFromObj = get(obj);

getFromObj(‘y’); // “there”
richdouglasevans
@richdouglasevans
Nov 29 2017 14:41
Ah! Thanks Bernat
Alec
@alavkx
Nov 29 2017 19:51
does anyone have any tips for using jsdoc with autocurried functions?
it seems anything that I wrap in curry is not getting picked up
the format I'm using is
/**
 * Returns a number that falls within the range passed closest to the value (x) that is passed
 * param  {number} min
 * param  {number} max
 * param  {number} x
 * returns number
 * example 
 * 
 *      const betweenZeroAndOneHundred = clamp(0, 100);
 *      map(betweenZeroAndOneHundred, [1, 3, 200, -15, 56, 120004]); //=> [1, 3, 100, 0, 56, 100] 
 */
clamp = curry((min: number, max: number, x: number): number => Math.max(Math.min(x, max), min)),
and exporting an object of all the functions
export {
clamp,
...other functions
};
Mike Lambert
@lambert-velir
Nov 29 2017 20:01
i use an atom plugin called docblockr
which generates jsdoc
i usually do /** to generate the jsdoc before adding R.curry
Alec
@alavkx
Nov 29 2017 20:04
Ah I'll give that a try
Thanks :)
Mike Lambert
@lambert-velir
Nov 29 2017 20:04
what do you mean by "is not getting picked up"?
Alec
@alavkx
Nov 29 2017 20:09
I should have specified, I'm consuming the jsdoc through intellisense
currently, the intellisense is just returning "import functionName"
Mike Lambert
@lambert-velir
Nov 29 2017 20:10
ahh i see, i'm not familiar with that
but maybe the format docblockr uses might work
Alec
@alavkx
Nov 29 2017 20:11
I'll check that out if your first suggestion doesn't work!
Mike Lambert
@lambert-velir
Nov 29 2017 20:11
don't you need @param?
Alec
@alavkx
Nov 29 2017 20:14
Seemingly. My first iteration had all the @ symbols, but I removed them according to the post here https://developercommunity.visualstudio.com/content/problem/49096/jsdoc-comment-support-in-typescript-intellisense-d.html
there is a bug that breaks any jsdoc line with an @ symbol when using vscode or visual studio.
I've jumped through a few hoops so far.. no reward yet ha