Created
June 1, 2020 10:37
-
-
Save tianyk/4e72bac246fc38db53e4e2d6c6c06ed6 to your computer and use it in GitHub Desktop.
This file contains 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 (...args) => { | |
return new Promise((resolve, reject) => { | |
fn(...args, (err, ...vals) => { | |
if (err) return reject(err); | |
resolve(...vals); | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment