Skip to content

Instantly share code, notes, and snippets.

@JayKan
Created January 4, 2019 11:48
Show Gist options
  • Select an option

  • Save JayKan/57d7fa62c2e902acdf3c05ba49976d40 to your computer and use it in GitHub Desktop.

Select an option

Save JayKan/57d7fa62c2e902acdf3c05ba49976d40 to your computer and use it in GitHub Desktop.
A tiny promisfy re-implmentation
// 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