Last active
July 7, 2018 12:01
-
-
Save olegpolyakov/b06a4f8b14aebabaf508248769e5eaff to your computer and use it in GitHub Desktop.
Promisify function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function promisify(fn) { | |
return function(...args) { | |
return new Promise((resolve, reject) => { | |
fn(...args, (error, data) => { | |
if (error) return reject(error); | |
resolve(data); | |
}); | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment