# promise-partial

> Partial (mixed) promise execution

Latest version **1.1.0** (published 2024-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise-partial
pnpm add promise-partial
yarn add promise-partial
bun add promise-partial
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-08-04 |
| First published | 2022-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nikita Galadiy |
| Maintainers | neki-development |
| Keywords | promise, partial, queue, async, await |

## Links

- npm: https://www.npmjs.com/package/promise-partial
- Repository: https://github.com/neki-dev/promise-partial
- Homepage: https://github.com/neki-dev/promise-partial#readme
- Issues: https://github.com/neki-dev/promise-partial/issues
- npm.io page: https://npm.io/package/promise-partial

## Alternatives

- [@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
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2024-08-04
- 1.0.15 — 2023-01-09
- 1.0.14 — 2022-09-28
- 1.0.13 — 2022-05-12
- 1.0.12 — 2022-04-07
- 1.0.11 — 2022-04-07
- 1.0.10 — 2022-04-04
- 1.0.9 — 2022-04-04
- 1.0.8 — 2022-04-04
- 1.0.7 — 2022-03-29
- 1.0.6 — 2022-03-28
- 1.0.5 — 2022-03-28
- 1.0.4 — 2022-03-28

## README

## ⚡ Promise partial
[![Version](https://badgen.net/npm/v/promise-partial)](https://npmjs.com/package/promise-partial)
[![Size](https://img.badgesize.io/neki-dev/promise-partial/master/dist/index.js)](https://github.com/neki-dev/promise-partial/blob/master/dist/index.js)
[![Build](https://github.com/neki-dev/promise-partial/actions/workflows/build.yml/badge.svg)](https://github.com/neki-dev/promise-partial/actions/workflows/build.yml)

Partial (mixed) promise execution

.

![Partial](https://i.ibb.co/J2ZcvzV/partial.png)

Array is divided on groups by _K_ items. Items in groups is handled in parallel. But groups are called in turn.
```ts
await promisePartial(items, someAsyncFunction, K)
```
.

For example - Default methods:

.

![Serial](https://i.ibb.co/n77YP3n/serial.png)

Each item of array is handled one by one. Like a simple `for`
```ts
for (const value of items) {
    await someAsyncFunction(value)
}
```

.

![Parallel](https://i.ibb.co/hM5RTC5/parallel.png)

Each item of array is handled in parallel. Like a `Promise.all`
```ts
await Promise.all(items.map(someAsyncFunction))
```

.

* ### Install

```sh
npm i promise-partial
```

* ### Usage

```ts
promisePartial<T, D>(
    // Array of items for map
    array: T[],
    // Callback for handle of item
    callback: (item: T, index: number) => Promise<D>,
    // Part size for array dividing
    partSize: number
): Promise<D>[]:
```

* ### Example

```ts
import promisePartial from 'promise-partial';

const items = [1, 2, 3, /* and more items */];
const partSize = 2;

const result = await promisePartial(items, async (value) => {
    return new Promise((resolve) => {
        // some async process
        setTimeout(() => resolve(value * 2), 100);
    });
}, partSize);
```

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