2.0.1 • Published 6 months ago

discrete-queue v2.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 months ago

Discrete Queue

version license issues language npm bundle size

Execute ordered list of functions. Add data-arguments and they will be passed to each function in the list:

import dQ from 'discrete-queue'
const car = { ... }; // Car object definition
dQ ( [ getTheCar, washIt, driveToTheGarage], car ).then ( result => .... )
/*          ^                                 ^               ^
/*          |                Extra data argument              |
            |                                                 |
            |                Array of function returns -------+
            |
            +---> list of tasks ( functions )          
*/

Installation

Install by writing in your terminal:

npm install discrete-queue --save

Once it has been installed, it can be used by writing this line of JavaScript:

import dQ from 'discrete-queue'

Task Functions

Every task function will receive two arguments. Task is an ask-for-promise object and controls execution of queue. Resolving the promise will start next task. Data is available for all functions in task list.

let myTask = ( task, data ) => {
           // ... do something here
           task.done ( 'myTaskResult' )   // finishing the task. Provide result if needed 
           // return task.promise // --> if function has asynchronous code and we have to wait until it is done
     }

Examples

Find some examples in ./test folder.

Known bugs

(Nothing yet)

Credits

'discrete-queue' was created by Peter Naydenov.

License

'discrete-queue' is released under the MIT License.

2.0.1

6 months ago

2.0.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.4

2 years ago

0.0.3

8 years ago

0.0.1

8 years ago