1.3.3 • Published 3 years ago

bim v1.3.3

Weekly downloads
59
License
ISC
Repository
github
Last release
3 years ago

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 }
1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.2

7 years ago

1.1.0

7 years ago

1.1.1

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago