Created
September 4, 2017 14:49
-
-
Save mpj/45626b14f1c7382eaddc96771beaf84d to your computer and use it in GitHub Desktop.
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
let createGetUserName = require('./di-lib.js') | |
const getUsername = createGetUserName(database) | |
getUserName(1).then(name => console.log('the name of user 1 is', name)) |
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
// notice: no require statement! | |
function createGetUserName(database) { | |
return function getUserName(id) { | |
return db.table('users').load(id) | |
.then(user => user.name) | |
} | |
} | |
module.exports = createGetUserName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment