Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bim

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bim

A bidirectional map based on the ES6 Map object containing additional methods to retrive keys by values, delete key-value pairs by values and check the existence of keys by values.

  • 1.0.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

bim

NPM version Downloads Dependency status Dev Dependency status

A bidirectional map based on the ES6 Map object containing additional methods to retrive keys by values, delete key-value pairs by values and check the existence of keys by values. The module contains two classes: BiMap & WeakBiMap based on Map & WeakMap respectively.

Installation

npm install --save bim

Usage

Same as normal Map & WeakMap, plus the getKey, hasValue & deleteValue methods.

import { WeakBiMap } from 'bim'

// create objects to use as keys
const a = {
  i: 'foo',
  j: 8,
}
const b = {
  k: 'bar',
  p: 11,
}

// create the bidirectional weak map
const wbm = new WeakBiMap()

wbm.set(a, 5)
wbm.set(b, 6)
wbm.deleteValue(5) // now only has { k: 'bar', p: 11 } => 6
wbm.hasValue(5) // false

const c = {
  h: 'quux',
  z: 100,
}

wbm.set(c, 7)
wbm.hasValue(7) // true
wbm.getKey(7) // { h: 'quux', z: 100 }

Keywords

FAQs

Package last updated on 15 Jan 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc