Skip to content

Instantly share code, notes, and snippets.

@mpj
Created September 4, 2017 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpj/45626b14f1c7382eaddc96771beaf84d to your computer and use it in GitHub Desktop.
Save mpj/45626b14f1c7382eaddc96771beaf84d to your computer and use it in GitHub Desktop.
let createGetUserName = require('./di-lib.js')
const getUsername = createGetUserName(database)
getUserName(1).then(name => console.log('the name of user 1 is', name))
// 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