# promise_array_parallel

> Manage arrays of Promise

Latest version **0.0.1-alpha.6** (published 2022-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise_array_parallel
pnpm add promise_array_parallel
yarn add promise_array_parallel
bun add promise_array_parallel
```

## 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.0.1-alpha.6 |
| Published | 2022-10-31 |
| First published | 2022-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 29.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | gunseikpaseri |
| Keywords | promise, parallel, semaphore, async |

## Links

- npm: https://www.npmjs.com/package/promise_array_parallel
- Repository: https://github.com/GunseiKPaseri/promise_array_parallel
- Homepage: https://github.com/GunseiKPaseri/promise_array_parallel#readme
- Issues: https://github.com/GunseiKPaseri/promise_array_parallel/issues
- npm.io page: https://npm.io/package/promise_array_parallel

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 0.0.1-alpha.6 (latest) — 2022-10-31
- 0.0.1-alpha.4 — 2022-10-28
- 0.0.1-alpha.2 — 2022-10-26

## README

# promise_array_parallel

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=square)](https://makeapullrequest.com)
[![Created by GunseiKPaseri](https://img.shields.io/badge/created%20by-@GunseiKPaseri-00ACEE.svg)](https://twitter.com/GunseiKPaseri)

![GitHub issues](https://img.shields.io/github/issues/GunseiKPaseri/promise_array_parallel)
![GitHub last commit](https://img.shields.io/github/last-commit/GunseiKPaseri/promise_array_parallel)

[![deno.land/x](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fpromise_array_parallel%2Fmod.ts)](https://doc.deno.land/https/deno.land/x/promise_array_parallel)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https://deno.land/x/promise_array_parallel/mod.ts)
![Package Dependencies Maintaind?](https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fupdates%2Fx%2Fpromise_array_parallel%2Fmod.ts)
[![nest.land](https://nest.land/badge.svg)](https://nest.land/package/promise_array_parallel)

[![npm version](https://img.shields.io/npm/v/promise_array_parallel?logo=npm)](https://badge.fury.io/js/promise_array_parallel)
![npm](https://img.shields.io/npm/dw/promise_array_parallel?logo=npm)

- Manage `Promise[]`.
  - Parallel execution of async function
  - Semaphore

There are no dependent packages, so it can be used in both Deno & npm environments.

## Example

See [./src/promise_array_parallel.test.ts](./src/promise_array_parallel.test.ts)

### Node

```bash
npm install promise_array_parallel
```

make `example.js`

```js
const PromiseArray = require('promise_array_parallel').PromiseArray

const sleep = (ms = 0) =>
  new Promise((res) => setTimeout(res, ms));

PromiseArray
    .from([...new Array(40)].map((_, i) => i < 20 ? 20 - i : i - 20))
    .parallelWork(async({idx, value}) => {
        await sleep(value * 10)
        console.log(idx)
    })
    .parallelWork(async({idx}) => {
        console.log("    " + idx)
    }, { priority: "INDEX" })
    
```

```bash
node ./example.js
```

### Deno

```ts
import {PromiseArray} from 'https://deno.land/x/promise_array_parallel/mod.ts'

const sleep = (ms = 0) =>
  new Promise((res) => setTimeout(res, ms));


PromiseArray
    .from([...new Array(40)].map((_, i) => i < 20 ? 20 - i : i - 20))
    .parallelWork(async({idx, value}) => {
        await sleep(value * 10)
        console.log(idx)
    })
    .parallelWork(async({idx}) => {
        console.log("    " + idx)
    }, { priority: "INDEX" })
    
```

## Develop This package

This package is developed in Deno; it is recommended to install Deno.

### Lint / Format / test

```bash
deno task test
```

### Generate NPM Package & Publish

```bash
deno task dnt
```

Automatically published when you push the tagged main branch

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