Skip to content

Instantly share code, notes, and snippets.

@jportella93
Created June 25, 2018 11:30
Show Gist options
  • Save jportella93/cf89f1cac0f631317d0ba8ec94aedf12 to your computer and use it in GitHub Desktop.
Save jportella93/cf89f1cac0f631317d0ba8ec94aedf12 to your computer and use it in GitHub Desktop.
const promisify = (fn) => (...args) => new Promise((resolve, reject) => {
fn.apply(insight, [...args, (err, ...args) => {
if (err) return reject(err);
resolve.apply(this, args);
}]);
});
// example:
// insight.getUnspentUtxosPromise = promisify(insight.getUnspentUtxos);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment