Skip to content

Instantly share code, notes, and snippets.

@loogle18
Created June 3, 2018 10:26
Show Gist options
  • Save loogle18/0ce436c8699894591ad61fa664e37b76 to your computer and use it in GitHub Desktop.
Save loogle18/0ce436c8699894591ad61fa664e37b76 to your computer and use it in GitHub Desktop.
const promisify = function(fn) {
return (...args) => {
return new Promise((resolve, reject) => {
fn(...args, function(err, result) {
if (err) {
reject(new Error(err));
} else {
resolve(result);
}
});
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment