Skip to content

Instantly share code, notes, and snippets.

@sabarasaba
Created July 16, 2013 15:21
Show Gist options
  • Save sabarasaba/6009716 to your computer and use it in GitHub Desktop.
Save sabarasaba/6009716 to your computer and use it in GitHub Desktop.
currying
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