# concurrent-pro

> Limit and prioritize the concurrency.

Latest version **0.1.1** (published 2022-07-13) · UNLICENSE (HTTP://UNLICENSE.ORG/) license · 0 weekly downloads

## Install

```sh
npm install concurrent-pro
pnpm add concurrent-pro
yarn add concurrent-pro
bun add concurrent-pro
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2022-07-13 |
| First published | 2022-07-12 |
| Weekly downloads | 0 |
| License | UNLICENSE (HTTP://UNLICENSE.ORG/) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | lbb |
| Maintainers | lbb00 |
| Keywords | concurrent, limit, priority, typescript |

## Links

- npm: https://www.npmjs.com/package/concurrent-pro
- Repository: https://github.com/lbb00/concurrent-pro
- Homepage: https://github.com/lbb00/concurrent-pro#readme
- Issues: https://github.com/lbb00/concurrent-pro/issues
- npm.io page: https://npm.io/package/concurrent-pro

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2022-07-13
- 0.1.0 — 2022-07-13
- 0.0.1 — 2022-07-12

## README

# concurrent-pro

[![Npm](https://badgen.net/npm/v/concurrent-pro)](https://www.npmjs.com/package/concurrent-pro)
[![Bundlephobia](https://badgen.net/bundlephobia/minzip/concurrent-pro)](https://bundlephobia.com/result?p=concurrent-pro)
[![Coverage](https://img.shields.io/codecov/c/github/lbb00/concurrent-pro.svg)](https://codecov.io/gh/lbb00/concurrent-pro)
[![License](https://img.shields.io/github/license/lbb00/concurrent-pro.svg)](https://github.com/lbb00/concurrent-pro/blob/master/LICENSE)
[![License](https://img.shields.io/npm/dt/concurrent-pro.svg)](https://www.npmjs.com/package/concurrent-pro)

Limit and prioritize the concurrency.

## Usage

```typescript
import { createConcurrent } from 'concurrent-pro'

function writToArr(i: number, arr: Array<number>): Promise<number> {
  return new Promise((resolve) => {
    setTimeout(() => {
      arr.push(i)
      resolve(i)
    }, 0)
  })
}

const concurrent = createConcurrent({
  limit: 1, // Only one promise is run at once
})

const arr = []
const [p1] = concurrent.execute(() => writToArr(1, arr))
const [p2] = concurrent.execute(() => writToArr(2, arr))
// High priority
const [p3] = concurrent.execute(() => writToArr(3, arr), 1)

await Promise.all([p1, p2, p3])

console.log(arr) // -> [1,3,2]
```

## Api

### createConcurrent(options)

- options
  - options.limit `number` default is Infinity.
  - options.defaultPriority `number` default is 0.

### concurrent.execute(fn ,priority)

- fn `() => Promise<T>`
- priority `number` default is options.defaultPriority

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