# queue-for-js

> queue queue.js 队列

Latest version **1.0.2** (published 2020-08-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install queue-for-js
pnpm add queue-for-js
yarn add queue-for-js
bun add queue-for-js
```

## 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.2 |
| Published | 2020-08-28 |
| First published | 2020-08-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | YuMu |
| Maintainers | yuqiongqianlimu |
| Keywords | 队列, queue, js |

## Links

- npm: https://www.npmjs.com/package/queue-for-js
- Repository: https://github.com/chentingjun/queue
- Homepage: https://github.com/chentingjun/queue#readme
- Issues: https://github.com/chentingjun/queue/issues
- npm.io page: https://npm.io/package/queue-for-js

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-08-28
- 1.0.1 — 2020-08-28
- 1.0.0 — 2020-08-27

## README

# Queue for js

代交向队列中添加数据，队列按顺序依次执行回调

## Use

```
const Queue = require('queue-for-js')

function printItem(item, done) {
  const t = Math.random() * 5000
  setTimeout(() => {
    console.log(item)
    done()
  }, t)
}

const q = new Queue({autoStart: true, limit: 10, callback: printItem})

q.push(1,2,3,4,5,6,7,8,9,10,11,12,13,14)
```
<img src="https://github.com/chentingjun/queue/blob/master/img/limit2.png?raw=true"><br />
```
q = new Queue({limit: 10, callback: printItem})

q.push(1,2,3,4,5,6,7,8,9,10,11,12,13,14)
```
<img src="https://github.com/chentingjun/queue/blob/master/img/limit10.png?raw=true"><br />

## config

#### `autoStart`
`default true` 实例化对像后是否直接执行队列<br >
#### `limit`
`default 10` 队列处理上线
#### `callback` params: item【队列项】 done【队列项处理结束回调-标记这项处理完毕，可以排出队列空间】
`callback` 处理队列项的回调

## Instance methods

`push()`
* 类似 array push, 可以添加数据列，也可以添加单项

`isEmpty()`
* 判断队列是否为空

`run()`
* 执行队列

`stop()`
* 暂停队列

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