Converts an asynchronous function to return a promise.
Promise
that calls the original function....
) to pass in all the parameters.util.promisify
.const promisify = func => (...args) =>
new Promise((resolve, reject) =>
func(...args, (err, result) => (err ? reject(err) : resolve(result)))
);
const delay = promisify((d, cb) => setTimeout(cb, d));
delay(2000).then(() => console.log('Hi!')); // Promise resolves after 2s
JavaScript, Function
Performs left-to-right function composition for asynchronous functions.
JavaScript, Function
Delays the execution of an asynchronous function.
JavaScript, Function
Creates a debounced function that returns a promise.