Skip to content

Instantly share code, notes, and snippets.

@cyan33
Created November 14, 2017 17:47
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 cyan33/c1e3e520f42fa549527399fc875262e4 to your computer and use it in GitHub Desktop.
Save cyan33/c1e3e520f42fa549527399fc875262e4 to your computer and use it in GitHub Desktop.
How the async wrapper is used
var login = async(function* (username, password, session) {
var user = yield getUser(username);
var hash = yield crypto.hashAsync(password + user.salt);
if (user.hash !== hash) {
throw new Error('Incorrect password');
}
session.setUser(user);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment