Socket
Socket
Sign inDemoInstall

async-map-like

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    async-map-like

ES6 Map TypeScript Interface with Async Support


Version published
Weekly downloads
1.3K
decreased by-27.63%
Maintainers
1
Install size
60.4 kB
Created
Weekly downloads
 

Readme

Source

async-map-like

NPM Version NPM TypeScript

ECMAScript Map like type definition (plus Async).

Async ES6 Map Like TypeScript Interface

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)

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

v0.2 (July 25, 2020)

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

Author

Huan LI (李卓桓), Microsoft AI MVP, zixia@zixia.net

Profile of Huan LI (李卓桓) on StackOverflow

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

Keywords

FAQs

Last updated on 27 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc