# simple-async-q

> A simple promise and event based async queue.

Latest version **0.0.1** (published 2018-01-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-async-q
pnpm add simple-async-q
yarn add simple-async-q
bun add simple-async-q
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2018-01-01 |
| First published | 2018-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | MSz |
| Maintainers | sys0 |

## Links

- npm: https://www.npmjs.com/package/simple-async-q
- Repository: https://github.com/Sys0MKNR/simple-async-q
- Homepage: https://github.com/Sys0MKNR/simple-async-q#readme
- Issues: https://github.com/Sys0MKNR/simple-async-q/issues
- npm.io page: https://npm.io/package/simple-async-q

## Recent versions

- 0.0.1 (latest) — 2018-01-01

## README

# simple-queue
A simple promise and event based async queue.

# Usage
```js
const Q = require('simple-async-q')

function fn () {
  return new Promise(async (resolve, reject) => {
   // some async stuff
  })
}

const q = new Q(fn)

q.add('test')
q.add('Test')

q.start()
```
# Constructor
> The provided function has to return a Promise.

# Functions

## start
>Start the queue.

## pause
>Pause the queue. The queue will be paused after the currently running task has finished. 

## resume
>Resume the queue. 

## kill
>Kill the queue(remove all added tasks). The queue will be killed after the currently running task has finished. 


# Events

## finished
> Is triggered when a task is finished. If no error occured then  _err_ is null. 
> Value has 2 attributes: value which holds the resolved value from the function and payload which is the value added on q.add.
```js
q.on('finished', (err, value) => {
})
```
## all-finished
> Is triggered when all tasks have been finished. 
```js
q.on('all-finished', () => {
})
```

## error
> Is triggered when an general error occurs. This event is not triggered when an error occurs inside the task function. 
```js
q.on('error', err => {
})
```

## License
MIT © [sys0](https://github.com/Sys0MKNR)

---
_Source: https://npm.io/package/simple-async-q · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
