Skip to content

Instantly share code, notes, and snippets.

@peter
Created May 26, 2015 08:57
Show Gist options
  • Save peter/b07ed9377153c5ced7e6 to your computer and use it in GitHub Desktop.
Save peter/b07ed9377153c5ced7e6 to your computer and use it in GitHub Desktop.
Ramda examples
'use strict';
var R = require('ramda');
var CATEGORIES = [
{category_type: 'cuisine', id: 1, name: 'French', type: 'categroy'},
{category_type: 'diets', id: 2, name: 'Vegetarian', type: 'category'}
];
var children = {
filter: function(type) {
return R.filter(R.propEq('category_type', type));
},
map: R.map(R.pick(['id', 'name', 'type'])),
byType: function(type) {
return R.compose(children.map, children.filter(type));
},
get: function(type) {
return children.byType(type)(CATEGORIES);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment