# @averagehelper/job-queue

> A simple queue for processing asynchronous tasks sequentially.

Latest version **3.0.1** (published 2026-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @averagehelper/job-queue
pnpm add @averagehelper/job-queue
yarn add @averagehelper/job-queue
bun add @averagehelper/job-queue
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2026-01-20 |
| First published | 2021-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 16.0.0 |
| Dependencies | 0 |
| Unpacked size | 19.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | AverageHelper |
| Maintainers | averagehelper |

## Links

- npm: https://www.npmjs.com/package/@averagehelper/job-queue
- Repository: https://git.average.name/AverageHelper/job-queue
- Homepage: https://git.average.name/AverageHelper/job-queue#readme
- Issues: https://git.average.name/AverageHelper/job-queue/issues
- npm.io page: https://npm.io/package/@averagehelper/job-queue

## Recent versions

- 3.0.1 (latest) — 2026-01-20
- 3.0.0 — 2024-02-19
- 2.1.0 — 2024-02-19
- 2.0.1 — 2023-12-17
- 2.0.0 — 2023-12-17
- 1.0.1 — 2021-12-02
- 1.0.0 — 2021-10-10
- 0.9.6 — 2021-10-10
- 0.9.5 — 2021-10-10
- 0.9.4 — 2021-10-10
- 0.9.3 — 2021-10-10
- 0.9.2 — 2021-10-10
- 0.9.1 — 2021-10-10
- 0.9.0 — 2021-10-10

## README

# job-queue

A simple queue for processing asynchronous tasks sequentially.

## Dependencies

This project requires [NodeJS](https://nodejs.org/) (version 16 or later).
To make sure you have them available on your machine,
try running the following command:

```sh
$ node -v
v16.6.2
```

## Installation

```sh
$ npm install @averagehelper/job-queue
```

## Usage

```ts
import { useJobQueue } from "@averagehelper/job-queue";

// Define your job type
interface Job {
	id: string;
	property1: string;
	property2: string;
}

async function processJob(job: Job): Promise<void> {
	// Do something with your job
}

const queue = useJobQueue<Job>("thing-queue"); // Create or retrieve a job queue
queue.process(processJob); // Add a processor function

// Handle queue event handlers
queue.on("start", () => {
	logger.debug("thing-queue has started processing jobs.");
});

queue.on("error", (error: unknown, failedJob: Job) => {
	logger.debug(`Job ${failedJob.id} failed with error`, error);
});

queue.on("finish", () => {
	logger.debug("thing-queue has finished processing all jobs.");
});

// Add jobs to process
queue.createJob({ property1, property2 });
queue.createJobs([job1, job2]);
```

## Contributing

We welcome contributions of all sorts!

1.  Fork it!
2.  Create your feature branch: `git checkout -b my-new-feature`
3.  Add your changes: `git add .`
4.  Commit your changes: `git commit -am 'Add some feature'`
5.  Push to the branch: `git push origin my-new-feature`
6.  Submit a pull request :sunglasses:

This project lives primarily at [git.average.name](https://git.average.name/AverageHelper/job-queue). A read-only mirror also exists on [GitHub](https://github.com/AverageHelper/job-queue). Issues or pull requests should be filed at [git.average.name](https://git.average.name/AverageHelper/job-queue). You may sign in or create an account directly, or use one of several OAuth 2.0 providers.

## Authors

- [**AverageHelper**](https://git.average.name/AverageHelper) - _Initial work_

## License

[MIT](LICENSE)

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