Skip to content

Instantly share code, notes, and snippets.

@KoryNunn
Created January 19, 2018 00:38
Show Gist options
  • Save KoryNunn/09c661d60ad2674de2ae834279e77660 to your computer and use it in GitHub Desktop.
Save KoryNunn/09c661d60ad2674de2ae834279e77660 to your computer and use it in GitHub Desktop.
https://www.toptal.com/javascript/asynchronous-javascript-async-await-tutorial but using normal callbacks, that don't catch exceptions, and implicitly handle rejections, using righto, also faster, and optimisable, because it doesn't use try/catch
const verifyUser = function(username, password, callback){
const userInfo = righto(dataBase.verifyUser, username, password);
const rolesInfo = righto(dataBase.getRoles, userInfo);
const logStatus = righto(dataBase.logAccess, userInfo, righto.after(rolesInfo));
const result = righto.mate(userInfo, righto.after(logStatus));
result(callback);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment