# async-map-like

> ES6 Map TypeScript Interface with Async Support

Latest version **1.0.2** (published 2021-11-27) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install async-map-like
pnpm add async-map-like
yarn add async-map-like
bun add async-map-like
```

## 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.2 |
| Published | 2021-11-27 |
| First published | 2020-07-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 59.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Huan |
| Maintainers | zixia |
| Keywords | async, map, typescript, interface |

## Links

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

## 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

- 1.0.2 (latest) — 2021-11-27
- 0.1.5 (next) — 2020-07-25
- 1.0.1 — 2021-11-27
- 0.2.5 — 2020-07-30
- 0.2.4 — 2020-07-30
- 0.2.3 — 2020-07-30
- 0.2.2 — 2020-07-30
- 0.2.1 — 2020-07-25
- 0.1.3 — 2020-07-25

## README

# async-map-like

[![NPM Version](https://img.shields.io/npm/v/async-map-like?color=brightgreen)](https://www.npmjs.com/package/async-map-like)
[![NPM](https://github.com/huan/async-map-like/actions/workflows/npm.yml/badge.svg)](https://github.com/huan/async-map-like/actions/workflows/npm.yml)
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue.svg)](https://www.typescriptlang.org/)

ECMAScript `Map` like type definition (plus Async).

[![Async ES6 Map Like TypeScript Interface](docs/images/async-es6-map.png)](https://github.com/huan/async-map-like)

It has same API Interface with [Map - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map - JavaScript | MDN"), with additional **Async** support.

## Usage

```ts
import { MapLike } from 'async-map-like'

const mapLike: MapLike<string, number> = new Map<string, number>
```

That's it, enjoy the [Duck Typing](https://en.wikipedia.org/wiki/Duck_typing)!

## API Reference

```ts
/**
 * ES6 Map like Async API
 */
export interface AsyncMapLike<K = any, V = any> {

  size : Promise<number>

  get     (key: K)           : Promise<V | undefined>
  set     (key: K, value: V) : Promise<void>
  has     (key: K)           : Promise<boolean>
  delete  (key: K)           : Promise<void>
  clear   ()                 : Promise<void>

  entries () : AsyncIterableIterator<[K, V]>
  keys    () : AsyncIterableIterator<K>
  values  () : AsyncIterableIterator<V>

  [Symbol.asyncIterator]() : AsyncIterableIterator<[K, V]>

  forEach (
    callbackfn: (
      value : V,
      key   : K,
      map   : AsyncMapLike<K, V>,
    ) => void,
    thisArg?: AsyncMapLike<K, V>,
  ): Promise<void>

}
```

## History

### master v1.0 (Nov 27, 2021)

1. Remove sync interface: `[Symbol.toStringTag]()` and `[Symbol.iterator]()`
1. Add async interface: `[Symbol.asyncIterator]()`

### v0.2 (July 25, 2020)

1. Create `MapLike` interface for ES6 Map
1. Create `AsyncMapLike` for ES6 Map like Async interface

## Author

[Huan LI](https://github.com/huan) ([李卓桓](http://linkedin.com/in/zixia)), Microsoft AI MVP, zixia@zixia.net

[![Profile of Huan LI (李卓桓) on StackOverflow](https://stackexchange.com/users/flair/265499.png)](https://stackexchange.com/users/265499)

## Copyright & License

* Docs released under Creative Commons
* Code released under the Apache-2.0 License
* Code & Docs © 2018 Huan LI \<zixia@zixia.net\>

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