JSPM

promised-map

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7649
  • Score
    100M100P100Q128811F
  • License MIT

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

Package Exports

  • promised-map

Readme

promised-map

Actions Status npm license

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

Installation

npm install promised-map

Usage

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