Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joeyfigaro
Last active June 16, 2017 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeyfigaro/10f7c778ee83f10e799df432864810bb to your computer and use it in GitHub Desktop.
Save joeyfigaro/10f7c778ee83f10e799df432864810bb to your computer and use it in GitHub Desktop.
Ramda Composition Example
const props = ['users', 'lessons', 'favorites', 'history'];
const selectProps = pick(props);
const stringify = compose(
JSON.stringify,
selectProps
);
stringify({
sensitive: {
hash: '!asdf#@hfASH234hdASHg1g1',
password: '*#YH!@G$**'
},
users: [
{ name: 'Joey', email: 'joey@joeyfigaro.com' },
{ name: 'Richard', email: 'richard.ricardo@gmail.com' }
],
lessons: [
{ name: 'function composition', favorites: 532, date_published: 'Thu Jun 15 2017 21:20:11 GMT-0400 (EDT)' }
]
});
// -> "{\"users\":[{\"name\":\"Joey\",\"email\":\"joey@joeyfigaro.com\"},{\"name\":\"Richard\",\"email\":\"richard.ricardo@gmail.com\"}],\"lessons\":[{\"name\":\"function composition\",\"favorites\":532,\"date_published\":\"Thu Jun 15 2017 21:20:11 GMT-0400 (EDT)\"}]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment