Last active
November 28, 2018 21:31
-
-
Save fauxsaurus/267e91b370880bcf83a580b4d06df406 to your computer and use it in GitHub Desktop.
Callback to promise
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
| function callback2promise(func,...args) | |
| { | |
| return new Promise(function(res,rej) | |
| { | |
| func(...args,(err,data)=>err?rej(err):res(data)) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment