These are chat archives for ramda/ramda

4th
Apr 2019
wangzengdi
@adispring
Apr 04 03:30
// I have an Friend data structure:
const friend = {
  name: String,
  ext: {
    remark: String,
    alias: String,
  }
}
const name = friend.name || friend.ext.remark
// If no `name` exists, will then use `remark`:
const name = R.converge(R.or, [R.path(['name'), R.path(['ext', 'remark']))(friend)

// how to write this in ramda style: get a `name` from more than 2 props
const nameFrom3OrMore = friend.name || friend.ext.remark || friend.ext.alias

const nameFrom3OrMoreRamda = ...
Andreas Herd
@mendrik
Apr 04 06:27
does ramda have a function to wrap a value in an array a -> [a] ?
Rakesh Pai
@rakeshpai
Apr 04 06:28
@mendrik JS does. Array.of(a) -> [a]
Andreas Herd
@mendrik
Apr 04 06:31
hmm but no ie11 support
would need a polyfill for that
Rakesh Pai
@rakeshpai
Apr 04 06:34
IE11, amirite! It's easy to polyfill though. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of#Polyfill But, yeah, not as convenient as Ramda having something built-in.
Fabien Bourgeois
@Yakulu
Apr 04 06:40
@mendrik R.of maybe ? https://ramdajs.com/docs/#of
Rakesh Pai
@rakeshpai
Apr 04 06:42
Oh! Learn about a new function every day! Thanks!
Fabien Bourgeois
@Yakulu
Apr 04 06:43
It may be like VIM, you never end learning :D
Rakesh Pai
@rakeshpai
Apr 04 06:44
Also, once you're into ramda, it's kinda hard to quit.
Andreas Herd
@mendrik
Apr 04 07:15
@rakeshpai well i'm stupid, I forgot I'm in nodejs env, so don't need ie11 :D
but ye R.of does the same
thanks!
Rakesh Pai
@rakeshpai
Apr 04 07:18
(y) I'd use Array.of if I'm in node, because JS built-in so fewer deps. But if it's for the browser, R.of would be better.
Andreas Herd
@mendrik
Apr 04 07:20
true that, but I got the dependency already, so either one works fine here
Ville Saukkonen
@villesau
Apr 04 14:04
Is there a smooth way to do inner join https://ramdajs.com/docs/#innerJoin where I would get list of tuples of both matched elements?
I'd expect innerJoin to do it but looks like it actually just takes intersection
hmm looks like there is an issue about it: ramda/ramda#2449