# promised-map

> A map of promises that can be resolved or rejected by key

Latest version **1.0.0** (published 2021-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install promised-map
pnpm add promised-map
yarn add promised-map
bun add promised-map
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-02-08 |
| First published | 2019-10-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 16.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Vitaliy Potapov |
| Maintainers | vitalets |
| Keywords | promise, promise-api, promises |

## Links

- npm: https://www.npmjs.com/package/promised-map
- Repository: https://github.com/vitalets/promised-map
- Homepage: https://github.com/vitalets/promised-map#readme
- Issues: https://github.com/vitalets/promised-map/issues
- npm.io page: https://npm.io/package/promised-map

## 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.0.0 (latest) — 2021-02-08
- 0.3.0 — 2021-01-26
- 0.2.0 — 2019-11-08
- 0.1.0 — 2019-10-20

## README

# promised-map
[![Actions Status](https://github.com/vitalets/promised-map/workflows/autotests/badge.svg)](https://github.com/vitalets/promised-map/actions)
[![npm](https://img.shields.io/npm/v/promised-map.svg)](https://www.npmjs.com/package/promised-map)
[![license](https://img.shields.io/npm/l/promised-map.svg)](https://www.npmjs.com/package/promised-map)

A map of promises that can be resolved or rejected by key.
Once promise is resolved/rejected, related key/value pair is automatically removed from map.

## Contents

<!-- toc -->

- [Installation](#installation)
- [Usage](#usage)
- [License](#license)

<!-- tocstop -->

## Installation
```bash
npm install promised-map
```

## Usage
```js
import { PromisedMap } from 'promised-map';

const map = new PromisedMap();

// set key/value pair and retrieve related promise.
const promise = map.set('foo', 42);

// resolve promise later by key
map.resolve('foo', 'bar');

// reject promise by key
map.reject('foo', new Error('error'));

// check if promise is still pending
map.has('foo');

// resolve all promises and clear map
map.resolveAll('bar');

// reject all promises and clear map
map.rejectAll(new Error('error'));

// iterate all promises
map.forEach((value, key) => { /* ... */ });
```

## License
MIT @ [Vitaliy Potapov](https://github.com/vitalets)

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