Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Last active September 26, 2019 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreasvirkus/f3117f84c097773f98d89d1d16fc39e0 to your computer and use it in GitHub Desktop.
Save andreasvirkus/f3117f84c097773f98d89d1d16fc39e0 to your computer and use it in GitHub Desktop.
// Needs spread operator (... notation)
export const promisify = (fn) => {
return (...args) => {
return new Promise((resolve, reject) => {
fn(...args, (err, res) => {
if (err) return reject(err)
return resolve(res)
})
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment