Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Last active November 21, 2016 23:58
Show Gist options
  • Save dengjonathan/7a854a04aee3e293083a3ed2e83ff52c to your computer and use it in GitHub Desktop.
Save dengjonathan/7a854a04aee3e293083a3ed2e83ff52c to your computer and use it in GitHub Desktop.
compose
const R = require('ramda');
const giveProp = (propName, prop, obj) => Object.assign({}, obj, {[propName]: prop});
const givePropCurry = R.curry(giveProp);
const giveName = givePropCurry('name');
const giveJob = givePropCurry('job');
const giveHero = givePropCurry('hero');
// Example 1: f(g(x))
const makeRen = obj => giveHero(
'Darth Vader',
giveName('Kylo')
);
// Example 2: using Ramda.compose
const makeRenCompose = R.compose(giveHero('Darth Vader'), giveName('Kylo'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment