Created
January 21, 2017 09:09
-
-
Save pnlybubbles/19b6a51dd614a3207636887951c5710b to your computer and use it in GitHub Desktop.
もっとつよいのあった→ https://www.npmjs.com/package/pify
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
module.exports = function promisify(f) { | |
return (...args) => { | |
return new Promise((resolve, reject) => { | |
f(...[...args, (err, data) => { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(data); | |
} | |
}]); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment