function promisify(fn) {
if (fn && typeof fn !== 'function') return
return (...args) => {
return new Promise((resolve, reject) => {
args.push(function cb(err, ...values) {
if (err) return reject(err)
return resolve(...values)
})
fn.call(this, ...args)
})
}
}