sortedmap
v0.0.2
Published
Adds value ordering to ecmascript Maps
Downloads
6
Readme
SYNOPSIS
INSTALL
npm install sortedmap
USAGE
const SortedMap = require('sortedmap')
const map = new SortedMap([
['a', 7],
['b', 1],
['c', 3]
], (a, b) => {
return a - b
})
map.get('a') // 7
map.set('z', 6)
[...map] // [['b', 1], ['c', 3], ['z', 6], ['a', 7]]
API
constructor
Creates a sorted map with all the method and properties of a regular JS Map
Parameters
values
Array<Array>? the intial values for the Mapcompare
Function A comparator function that takes two arguments and returns a number. The first argument will be a member of sortedArray, the second argument will be item. If item < member, return value < 0 If item > member, return value > 0