Proxy-Powered Promisification for your Pleasure
npm install promwrapWraps modules, and other objects, full of callback functions in promises.
``javascript
let fun = (x, cb) => cb(null, x)
let _module = {fun, prop: 'test'}
test('test basics', async t => {
t.plan(4)
let mod = promwrap(_module)
t.same(mod.prop, 'test')
t.same(mod.prop, 'test')
t.same(await mod.fun('test1'), 'test1')
t.same(await promwrap(fun)('test2'), 'test2')
})
`
Promisify all function properties of value. If value is a Function,Object.prototype
it will be promisified instead. Members of are not
promisified.
Returns value, wrapped by a Proxy.
- If exclude is supplied, do not promisify this prop/list of props.excludeMain
- If is truthy and value is a Function, treat value like aObject
plain and promisify its props instead of value itself. In Function.prototype
addition, members of will not be promisified.own
- If is truthy, only promisify the Object's "own" (in the Object.hasOwnProperty()` sense) props