Bi Directional Map ( BIDI Map ) for NodeJS
npm install @psenger/bidirectional-map> A bidirectional map, is an associative data structure in which the pairs form a one-to-one
> relationship. The binary relation is functional in both direction: each value is mapped to a
> unique key.
Extends Map
* See: [wikipedia][1] for further information
Bi Directional Map is a Map, in which the keys and values are registered pointing to each
other ( a binary relationship ). EG A->B and B->A. This is a Advanced Data Type and is some times
called an Associative Data Structure.
Type: [BiDirectionalMap][2]
#### Parameters
* props Iterable? An Iterable object whose elements are key-value pairs (arrays with two elements, e.g. \[\[ 1, \['one','two'] ],\[ 2, \['three'] ]]). Each key-value pair is added to the new Map; null values are treated as undefined.
Meta
* version: 1.0.5
#### set
Sets the value for the key in the Map object. Overriding the parent set and returns the Map
object. Only works with String or \Numbers.
##### Parameters
* key ([string][3] | [number][4]) The key of the element to add to the BiDirectionalMap object.value
* ([string][3] | [number][4]) The value of the element to add to the BiDirectionalMap object.
Returns [BiDirectionalMap][2]
#### species
Overwrite BiDirectionalMap species to the parent Map constructor
Returns MapConstructor
[1]: https://en.wikipedia.org/wiki/Bidirectional_map
[2]: #bidirectionalmap
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
`javascriptKey(1) = Value(${bidiMap.get(1)})
const bidiMap = new BiDirectionalMap();
bidiMap.set(1, 2).set(3, 4);
console.log ( );Key(2) = Value(${bidiMap.get(2)})
console.log ( );Key(3) = Value(${bidiMap.get(3)})
console.log ( );Key(4) = Value(${bidiMap.get(4)})
console.log ( );Key(${Key}) = Value(${Value})
// Key(1) = Value(2)
// Key(2) = Value(1)
// Key(3) = Value(4)
// Key(4) = Value(3)
for( let [Key,Value] of bidiMap.entries()){
console.log();`
}
// Key(1) = Value(2)
// Key(2) = Value(1)
// Key(3) = Value(4)
// Key(4) = Value(3)
`bash`
npm install @psenger/bidirectional-map --save
or
`bash`
yarn add @psenger/bidirectional-map
MIT License
Copyright (c) 2021 Philip A Senger
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
* create a pull request from dev to mainmain
* check out npm version patch -m "message here" or minor
* npm publish
* dev
* Then switch to branchmain
* And then merge into dev and push dev` to origin