# ready-queue

> Ready-queue ensures initialization method only run once, and queues listeners which are registered to it.

Latest version **1.0.0** (published 2016-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install ready-queue
pnpm add ready-queue
yarn add ready-queue
bun add ready-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.0 |
| Published | 2016-10-16 |
| First published | 2016-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | kaelzhang |
| Maintainers | kael |
| Keywords | ready-queue, queue, ready, retry, promise |

## Links

- npm: https://www.npmjs.com/package/ready-queue
- Repository: https://github.com/kaelzhang/node-ready-queue
- Homepage: https://github.com/kaelzhang/node-ready-queue#readme
- Issues: https://github.com/kaelzhang/node-ready-queue/issues
- npm.io page: https://npm.io/package/ready-queue

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-10-16
- 0.0.0 — 2016-10-16

## README

[![Build Status](https://travis-ci.org/kaelzhang/node-ready-queue.svg?branch=master)](https://travis-ci.org/kaelzhang/node-ready-queue)
<!-- optional appveyor tst
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/kaelzhang/node-ready-queue?branch=master&svg=true)](https://ci.appveyor.com/project/kaelzhang/node-ready-queue)
-->
<!-- optional npm version
[![NPM version](https://badge.fury.io/js/ready-queue.svg)](http://badge.fury.io/js/ready-queue)
-->
<!-- optional npm downloads
[![npm module downloads per month](http://img.shields.io/npm/dm/ready-queue.svg)](https://www.npmjs.org/package/ready-queue)
-->
<!-- optional dependency status
[![Dependency Status](https://david-dm.org/kaelzhang/node-ready-queue.svg)](https://david-dm.org/kaelzhang/node-ready-queue)
-->

# ready-queue

Ready-queue ensures initialization method only run once, and queues listeners which are registered to it.

## Install

```sh
$ npm install ready-queue --save
```

## Usage

```js
const queue = require('ready-queue')

const q = queue({
  load: (userId) => {
    return getUserPromise(userId)
  }
})

q.add(123).then((userObject) => {
  userObject
})

q.add(123).then((userObject) => {
  // `getUserPromise(123)` only runs once
})

q.add(234).then((userObject) => {
  // then `getUserPromise(234)` runs
})
```

### queue({load, retry = 0})

- **load** `function(args)` if the function is asynchronous, it should return a `Promise`.
  - args `any` arguments which is from `.add(args)` method
- **retry** `number=0` how many times `queue` will retry if fails.

### .add(args)

returns `Promise`

## License

MIT

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