Created
June 4, 2015 12:13
-
-
Save jimmymain/092bd7aade51a4d5a28b to your computer and use it in GitHub Desktop.
ramda
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
http://jsfiddle.net/CrossEye/Gk6uu/light/ | |
(function(R) { | |
var incomplete = R.filter(R.where({complete: false})); | |
var sortByDate = R.sortBy(R.prop('dueDate')); | |
var sortByDateDescend = R.compose(R.reverse, sortByDate); | |
var importantFields = R.project(['title', 'dueDate']); | |
var groupByUser = R.partition(R.prop('username')); | |
var activeByUser = R.compose(groupByUser, incomplete); | |
var gloss = R.compose(importantFields, R.take(5), sortByDateDescend); | |
var topData = R.compose(gloss, incomplete); | |
var topDataAllUsers = R.compose(R.mapObj(gloss), activeByUser); | |
var byUser = R.use(R.filter).over(R.propEq("username")); | |
log("Gloss for Scott:"); | |
log(topData(byUser("Scott", tasks))); | |
log("===================="); | |
log("Gloss for everyone:"); | |
log(topDataAllUsers(tasks)); | |
}(ramda)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment