-
-
Save phpsmarter/5484d7859f24a2fd782a8a4a90faa5d0 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