Created
March 11, 2017 16:51
-
-
Save ruanyf/728d1fc9117d86f1bc728afc2272fb32 to your computer and use it in GitHub Desktop.
Pointfree Demo 03
This file contains hidden or 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
var data = { | |
result: "SUCCESS", | |
interfaceVersion: "1.0.3", | |
requested: "10/17/2013 15:31:20", | |
lastUpdated: "10/16/2013 10:52:39", | |
tasks: [ | |
{id: 104, complete: false, priority: "high", | |
dueDate: "2013-11-29", username: "Scott", | |
title: "Do something", created: "9/22/2013"}, | |
{id: 105, complete: false, priority: "medium", | |
dueDate: "2013-11-22", username: "Lena", | |
title: "Do something else", created: "9/22/2013"}, | |
{id: 107, complete: true, priority: "high", | |
dueDate: "2013-11-22", username: "Mike", | |
title: "Fix the foo", created: "9/22/2013"}, | |
{id: 108, complete: false, priority: "low", | |
dueDate: "2013-11-15", username: "Punam", | |
title: "Adjust the bar", created: "9/25/2013"}, | |
{id: 110, complete: false, priority: "medium", | |
dueDate: "2013-11-15", username: "Scott", | |
title: "Rename everything", created: "10/2/2013"}, | |
{id: 112, complete: true, priority: "high", | |
dueDate: "2013-11-27", username: "Lena", | |
title: "Alter all quuxes", created: "10/5/2013"} | |
// , ... | |
] | |
}; | |
var fetchData = function () { | |
return Promise.resolve(data); | |
}; | |
var getIncompleteTaskSummaries = function(membername) { | |
return fetchData() | |
.then(R.prop('tasks')) | |
.then(R.filter(R.propEq('username', membername))) | |
.then(R.reject(R.propEq('complete', true))) | |
.then(R.map(R.pick(['id', 'dueDate', 'title', 'priority']))) | |
.then(R.sortBy(R.prop('dueDate'))); | |
}; | |
getIncompleteTaskSummaries('Scott').then(r => console.log(r)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment