Ordered Map implementation for JavaScript
npm install @otaxhu/orderedmapYou can think of this OrderedMap as a regular JavaScript Map, but where you can get the previous and next elements of any of the entries in the OrderedMap without knowing their keys.
In fact OrderedMap extends Map standard JavaScript class, so you can use this implementation as a regular JavaScript Map.
OrderedMap extends Map, meaning that all of the methods and properties from Map are also available with no behaviour change on them.See MDN Docs Map website for more information.
### New methods
- #### .getElement(key: K): Element
Gets an element with key key previously setted (either through the constructor or .set() method), and returns an object with the following type:
``ts`
type Element
readonly key: K,
readonly value: V,
readonly nextElement?: Element
readonly prevElement?: Element
}
undefined
Or if an element with that key was not found in the OrderedMap.
- #### .front(): Element
Returns the first element in the OrderedMap as an Element object type, or undefined if the OrderedMap is empty.
- #### .back(): Element
Returns the last element in the OrderedMap as an Element object type, or undefined if the OrderedMap is empty.