Promisify.js
by joplomacedo
JavaScript
//accepts function of type (...args, successCb, errorCb ) and turns it into a Promise function
const Promisify = (f, ctx = null) => {
return function(...args) {
return new Promise((resolve, reject) => {
f.call(ctx, ...args, res => {
resolve(res);
}, err => {
reject(err);
});
});
};
};