1.0.9 • Published 4 years ago

extra-bimap v1.0.9

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

A bi-directional map, with unique keys to unique values. Internally, its a map and its inverse map which allows value to be looked up through key, and key through value. Eg. email id <-> person name.

const BiMap = require('extra-bimap');
// : all Map() functions available

var m = new BiMap();
// BiMap [Map] {}

m.set(1, 'a');
// BiMap [Map] { 1 => 'a' }

m.set(2, 'b');
// BiMap [Map] { 1 => 'a', 2 => 'b' }

m.set(2, 'a');
// Error: BiMap pair is not unique

m.inverse;
// BiMap [Map] { 'a' => 1, 'b' => 2 }

m.inverse.set('a', 2);
// Error: BiMap pair is not unique

m.inverse.set('b', 3);
// BiMap [Map] { 'a' => 1, 'b' => 3 }

m.inverse.inverse
// BiMap [Map] { 1 => 'a', 3 => 'b' }

m.delete(1);
// BiMap [Map] { 3 => 'b' }

m.inverse.has('a')
// false

reference

NameAction
BiMapCreates a bi-directional map, with unique keys to unique values.
inverseGives reversed bi-directional map.
clearRemoves all elements from map.
deleteRemoves the specified element from map.
setAdds or updates an element with a specified key and a value to map.
sizeSame as Map.
entriesSame as Map.
forEachSame as Map.
getSame as Map.
hasSame as Map.
keysSame as Map.
valuesSame as Map.
@@iteratorSame as Map.

nodef

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago