Methods
(static) promisify(fn) → {function}
promisify async callback functions (arg1, arg2, cb) => {}
become
(arg1, arg2) => Promise
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | async function using callbacks |
- Source:
Returns:
returning Promise
- Type
- function
Example
const fn = (timeout, payload, cb) =>
setTimeout(() => cb(null, payload), timeout)
const promise = promisify(fn)
promise(10, 'a').then((res) => {
//> res = 'a'
})