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);
});
};
};