sorted-value-map
v1.0.0
Published
Map sorted by value
Downloads
3
Maintainers
Readme
sorted-value-map
Map with sorted values.
Install
npm install sorted-value-map
Usage
const { SortedValueMap } = require('sorted-value-map')
const map = new SortedValueMap((a, b) => {
if (a < b) return -1
else if (a > b) return 1
else return 0
})
map.insert("key-a", 8)
map.insert("key-b", 2)
for (const a of map.values()) {
console.log(a) // 2, 8
}
API
SortedValueMap uses the same API as the official Map.
const map = new SortedValueMap([comparator])
map.insert(key, value)
map.remove(key)
map.size
map.clear()
map.entries()
map.keys()
map.values()
License
MIT. Copyright (c) Alex