Skip to content

Instantly share code, notes, and snippets.

@devsnek
Created December 12, 2016 23:41
Show Gist options
  • Save devsnek/9eab7bcc01eef7656eb899a94effc46a to your computer and use it in GitHub Desktop.
Save devsnek/9eab7bcc01eef7656eb899a94effc46a to your computer and use it in GitHub Desktop.
also here's a promisify that blows bluebird out of the water.
function promisify (fn, thisArg = null) {
return (...args) => {
return new Promise((resolve, reject) => {
const callback = (err, res) => {
if (err) return reject(err);
return resolve(res);
}
fn.apply(thisArg, [...args, callback]);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment