-
-
Save phpsmarter/514da18898d8b9ba9f71b3d66f3cc7c1 to your computer and use it in GitHub Desktop.
Ramda examples
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
'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