Skip to content

Instantly share code, notes, and snippets.

@max-lt
Created May 22, 2017 18:58
Show Gist options
  • Save max-lt/046add754246e6ba26426c7805866591 to your computer and use it in GitHub Desktop.
Save max-lt/046add754246e6ba26426c7805866591 to your computer and use it in GitHub Desktop.
promisify polyfill
// usage: promisify(instance.func.bind(instance))
function promisify(fun) {
return function (...args) {
return new Promise((resolve, reject) => {
fun.apply(fun, [].concat(args, (err, res) => (err) ? reject(err) : resolve(res)))
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment