Created
June 3, 2017 21:14
-
-
Save BnayaZil/88f2505a1771924bb1a40c9e017b5902 to your computer and use it in GitHub Desktop.
Ramda series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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