Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 23:26
Show Gist options
  • Save anonymous/4333045 to your computer and use it in GitHub Desktop.
Save anonymous/4333045 to your computer and use it in GitHub Desktop.
What would this function look like with addAdminUser, db.addUser and dbUser.setPermissions taking two callbacks?
# add an admin user. cb will receive an error
# (or null if there isn't a problem) and a
# flag indicating success
addAdminUser = ( username, cb ) ->
db.addUser username, ( err, dbUser ) ->
return cb err if err
dbUser.setPermissions "admin", ( err, dbPermission ) ->
return cb err, false if err
return cb null, true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment