Last active
September 26, 2019 11:24
-
-
Save andreasvirkus/f3117f84c097773f98d89d1d16fc39e0 to your computer and use it in GitHub Desktop.
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
// Needs spread operator (... notation) | |
export const promisify = (fn) => { | |
return (...args) => { | |
return new Promise((resolve, reject) => { | |
fn(...args, (err, res) => { | |
if (err) return reject(err) | |
return resolve(res) | |
}) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment