Skip to content

nak2k/node-task-waiter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Wait a task is completed.

Resources

Stars

Watchers

Forks

Packages

No packages published