Created
November 16, 2016 21:26
-
-
Save zspecza/169a51e0dbfafe6bcb7b4fa5906f350c to your computer and use it in GitHub Desktop.
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
const users = { | |
1: { name: 'bob' }, | |
2: { name: 'sally' } | |
} | |
const posts = [ | |
{ author: 'sally', title: 'Hello World' }, | |
{ author: 'bob', title: 'How to do stuff' } | |
] | |
const getUserName = sequentialCallback( | |
(id, callback) => callback(null, users[id]), | |
(user, callback) => callback(null, user.name) | |
) | |
const getUserPosts = sequentialCallback( | |
getUserName, | |
(name, callback) => callback(null, posts.filter((p) => p.author === name)) | |
) | |
getUserPosts(2, (err, posts) => { | |
console.log(posts) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment