# async-promise-queue

> wrapper around async.queue to make some common usages simpler

Latest version **1.0.5** (published 2019-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install async-promise-queue
pnpm add async-promise-queue
yarn add async-promise-queue
bun add async-promise-queue
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2019-05-10 |
| First published | 2017-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Stefan Penner |
| Maintainers | stefanpenner |

## Links

- npm: https://www.npmjs.com/package/async-promise-queue
- Repository: https://github.com/stefanpenner/async-promise-queue
- Homepage: https://github.com/stefanpenner/async-promise-queue#readme
- Issues: https://github.com/stefanpenner/async-promise-queue/issues
- npm.io page: https://npm.io/package/async-promise-queue

## Dependencies (2)

- [async](https://npm.io/package/async.md) ^2.4.1
- [debug](https://npm.io/package/debug.md) ^2.6.8

## Recent versions

- 1.0.5 (latest) — 2019-05-10
- 1.0.4 — 2017-07-26
- 1.0.3 — 2017-06-30
- 2.4.2 — 2017-06-30
- 1.0.2 — 2017-06-05
- 1.0.1 — 2017-06-05
- 1.0.0 — 2017-06-05

## README

# async-promise-queue

[![Build Status](https://travis-ci.org/stefanpenner/async-promise-queue.svg?branch=master)](https://travis-ci.org/stefanpenner/async-promise-queue)

A wrapper around the `async` module, that provides an improved promise queue.

Some highlights:

* promiseified method (all wired up)
* in a failure scenario, it will wait for pending work before rejecting. This prevents the run-away work problem.

## Usage

```sh
npm install async-promise-queue
```

or

```sh
yarn add async-promise-queue
```

### Debug logging

```
DEBUG="async-promise-queue*" node <your program>
```

And you will be informed when a queue is used, and what its concurrency becomes (note: we can always add more logging, submit your ideas as pull requests!)

## Example

```js
'use strict';

const queue = require('async-promise-queue');

queue.async // a reference to the `async` module which `async-promise-queue` is requiring.

// the example worker
const worker = queue.async.asyncify(function(work) {
  console.log('work', work.file);
  return new Promise(resolve => {
    if (work.file === '/path-2') { throw new Error('/path-2'); }
    if (work.file === '/path-3') { throw new Error('/path-3'); }
    setTimeout(resolve, work.duration);
  });
});

// the work
const work = [
  { file:'/path-1',  duration: 1000 },
  { file:'/path-2',  duration: 50 },
  { file:'/path-3',  duration: 100 },
  { file:'/path-4',  duration: 50 },
];

// calling our queue helper
queue(worker, work, 3)
  .catch(reason => console.error(reason))
  .then(value   => console.log('complete!!', value))
```

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