0.1.1 • Published 6 years ago

task-waiter v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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