Last active
February 26, 2020 13:36
-
-
Save commenthol/a8e28768447f64b7fdc411b27349134c to your computer and use it in GitHub Desktop.
promisify
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
const promisify = (fn) => ( | |
(...args) => ( | |
new Promise((resolve, reject) => { | |
fn(...args, (err, ...res) => { | |
if (err) reject(err) | |
else resolve(...res) | |
}) | |
}) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment