UNPKG

@entrylabs/bindings

Version:
21 lines (19 loc) 381 B
function promisify(func) { if (typeof func !== 'function') { throw new Error('"func" must be a function') } return function(...args) { return new Promise((resolve, reject) => { args.push((err, data) => { if (err) { return reject(err) } resolve(data) }) func(...args) }) } } module.exports = { promisify, }