Skip to content

Instantly share code, notes, and snippets.

@BnayaZil
Created June 3, 2017 21:14
Show Gist options
  • Save BnayaZil/88f2505a1771924bb1a40c9e017b5902 to your computer and use it in GitHub Desktop.
Save BnayaZil/88f2505a1771924bb1a40c9e017b5902 to your computer and use it in GitHub Desktop.
Ramda series
import {prop, compose, apply, defaultTo, juxt} from 'ramda'
const player = {
id: 1,
name: 'Bnaya',
file: {
img: 'http://foo.bar/bnaya-zil.png'
}
}
const getFile = prop('file')
const getThumb = prop('thumb')
const getImg = prop('img')
const getFileContent = juxt([getImg, getThumb])
const reduceFileContent = apply(defaultTo)
const getPlayerPicture = compose(reduceFileContent, getFileContent, getFile)
const playerPicture = getPlayerPicture(player) // returns: 'http://foo.bar/bnaya-zil.png'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment