how to promisify a callback code example
Example: js promisify in browser
function promisify(func, callbackPos) {
return (...args) => {
return new Promise((resolve) => {
const cb = (...args) => {
resolve(args);
};
args.splice(callbackPos ? callbackPos : args.length, 0, cb);
func(...args);
});
};
};