Skip to content

Instantly share code, notes, and snippets.

@phpsmarter
Forked from BnayaZil/code02.js
Last active January 16, 2018 08:47
Show Gist options
  • Save phpsmarter/5484d7859f24a2fd782a8a4a90faa5d0 to your computer and use it in GitHub Desktop.
Save phpsmarter/5484d7859f24a2fd782a8a4a90faa5d0 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