Last active
November 3, 2017 16:06
-
-
Save cyan33/d93a33466b8a15fe2f098b668b01a723 to your computer and use it in GitHub Desktop.
tiny promisify
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 promisify(fn) { | |
return function(...args) { | |
return new Promise((res, rej) => { | |
fn(...args, function() { | |
res(arguments) | |
}) | |
}) | |
} | |
} | |
// this could be retrieved in nodejs by | |
// const { promisify } = require('util') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment