0.1.1 • Published 7 years ago
task-waiter v0.1.1
task-waiter
Wait a task is completed.
Installation
npm i task-waiterUsage
const { wait } = require('task-waiter');
const then = wait(callback => {
// Do something
callback(null, 1, 2, 3);
});
then((err, ...args) => {
// args is [1, 2, 3]
});wait(task)
task(callback)- A task funciton to wait for completion.
- The
callbackfunction must be called with any number of arguments when the task is completed.
This function returns a following function:
then(callback)- A function to specify a function that is called after the task is completed.
- The
callbackfunction is called with arguments that are passed when the callback of the task is called.
lazy(task)
This function can be called the same as wait(task) except the task is called after the first then function call.
License
MIT