README
ordered-map-arrays
is a type of ordered map where all values are by default
stored in array for a given key.
Ships with Typescript support.
Usage
.push(key: number, value: T)
Add your value for the given key. If a value exists at the key, your value is added after it, but before the next key in the order.
; map.push1, 'foo'map.push2, 'bar'map.push3, 'baz'map.push1, 'foobar' console.logmap.toArray // prints ['foo', 'foobar', 'bar', 'baz']
.set(key: number, value: T)
Set the value for the key. This removes any existing values at the key.
; map.push1, 'foo'map.push1, 'bar'map.push1, 'baz'map.set1, 'example' map.get1 // returns ['example']
.get(key: number): T[]
Return the values for a given key in their order:
; map.push1, 'foo'map.push1, 'bar'map.push1, 'foobar' map.get1 // returns ['foo', 'bar', 'foobar']
.prepend(key: number, value: T)
Prepend a value at the key:
; map.push1, 'foo'map.push1, 'bar'map.prepend1, 'foobar' map.get1 // returns ['foobar', 'foo', 'bar']
.concat(key: number, value: T[])
Concat values for the given key
; map.push1, 'foo'map.push1, 'bar'map.concat1, map.get1 // returns ['foo', 'bar', 'foobar', 'foobaz']
.values(): T[]
Returns values in their order by key
; map.push1, 'foo'map.push1, 'bar'map.push2, 'foobar'map.push3, 'foobaz' map.values // returns ['foo', 'bar', 'foobar', 'foobaz']
.keys(): number[]
Returns the map's keys in order:
; map.push-10, 'foobar'map.push0, 'foo'map.push10, 'foo'map.push100, 'bar'map.push999, 'foobaz' map.keys // returns [-10, 0, 10, 100, 999]