https://github.com/peternaydenov/discrete-queue
Execute list of asynchronous functions in order
https://github.com/peternaydenov/discrete-queue
Last synced: about 1 month ago
JSON representation
Execute list of asynchronous functions in order
- Host: GitHub
- URL: https://github.com/peternaydenov/discrete-queue
- Owner: PeterNaydenov
- License: mit
- Created: 2017-02-18T15:06:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-02-17T06:25:38.000Z (4 months ago)
- Last Synced: 2025-04-05T18:54:01.828Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 124 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# Discrete Queue




Execute ordered list of functions. Add data-arguments and they will be passed to each function in the list:
```js
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:
```js
import dQ from 'discrete-queue'```
## Task Functions
Every task function will receive two arguments. Task is an [**ask-for-promise**](https://github.com/PeterNaydenov/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.```js
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](https://github.com/PeterNaydenov/discrete-queue/blob/master/LICENSE).