Created
January 19, 2019 10:19
-
-
Save sonufrienko/44b4947caa579ad739de1547653efdc5 to your computer and use it in GitHub Desktop.
Custom JavaScript Promisify function
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 = f => (...args) => | |
new Promise((resolve, reject) => { | |
f(...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
Variant 1 - use Node.js util
Variant 2 - use custom function