Created
July 16, 2013 15:21
-
-
Save sabarasaba/6009716 to your computer and use it in GitHub Desktop.
currying
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
var o = '{ "user": "tu vieja", "posts": [ { "title": "title 1", "contents": "..." }, { "title": "title 2", "contents": "..." } ] }'; | |
var fetchShit = function() { | |
var def = $.Deferred(); | |
setTimeout(function() { | |
def.resolve(o); | |
}, 2000); | |
return def.promise(); | |
}; | |
fetchShit() | |
.then(JSON.parse) | |
.then(function(data){ return data.posts }) | |
.then(function(posts){ | |
return posts.map(function(post){ return post.title }) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment