task-waiter
v0.1.1
Published
Wait a task is completed
Downloads
6
Readme
task-waiter
Wait a task is completed.
Installation
npm i task-waiter
Usage
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
callback
function 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
callback
function 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