Created
January 4, 2019 11:48
-
-
Save JayKan/57d7fa62c2e902acdf3c05ba49976d40 to your computer and use it in GitHub Desktop.
A tiny promisfy re-implmentation
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
| // Keep in mind this could be simply retrieved in nodejs by | |
| // const { promisify } = require('util'); | |
| function promisify(fn) { | |
| return function(...args) { | |
| return new Promise((res, rej) => { | |
| fn(...args, function() { | |
| res(arguments) | |
| }) | |
| }) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment