Skip to content

Instantly share code, notes, and snippets.

@crutchcorn
Created January 13, 2022 01:47
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 crutchcorn/8cdb0a7b2231cbd1bc216e4a780716be to your computer and use it in GitHub Desktop.
Save crutchcorn/8cdb0a7b2231cbd1bc216e4a780716be to your computer and use it in GitHub Desktop.
const promisify = (fn) => {
return (...args) => {
return new Promise(resolve => {
fn(...args, (...data) => resolve(...data))
})
}
}
promisify((one, cb) => cb(one))(1).then(one => console.log(one))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment