|
|
||
|---|---|---|
| .. | ||
| .github/workflows | ||
| .vscode | ||
| dist | ||
| scripts | ||
| src | ||
| tests | ||
| .editorconfig | ||
| .eslintrc.cjs | ||
| LICENSE | ||
| NOTICE | ||
| README.md | ||
| package.json | ||
| tsconfig.cjs.json | ||
| tsconfig.json | ||
README.md
async-map-like
ECMAScript Map like type definition (plus Async).
It has same API Interface with Map - JavaScript | MDN, with additional Async support.
Usage
import { MapLike } from 'async-map-like'
const mapLike: MapLike<string, number> = new Map<string, number>
That's it, enjoy the Duck Typing!
API Reference
/**
* 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)
- Remove sync interface:
[Symbol.toStringTag]()and[Symbol.iterator]() - Add async interface:
[Symbol.asyncIterator]()
v0.2 (July 25, 2020)
- Create
MapLikeinterface for ES6 Map - Create
AsyncMapLikefor ES6 Map like Async interface
Author
Huan LI (李卓桓), Microsoft AI MVP, zixia@zixia.net
Copyright & License
- Docs released under Creative Commons
- Code released under the Apache-2.0 License
- Code & Docs © 2018 Huan LI <zixia@zixia.net>

