cartographic
v0.0.2
Published
tacit Map tooling
Downloads
1
Readme
Cartographic
Tacit functions for interacting with native JS Maps
API
of
Tacit constructor
import { of } from 'cartographic'
of([['a', 1], ['b', 2]]) === Map([['a', 1], ['b', 2]])
size
Get the size of a Map
import { of, size } from 'cartographic'
const two = of([['a', 1], ['b', 2]])
size(two) === 2
clear
Clear a Map of all records
import { of, clear, size } from 'cartographic'
const two = of([['a', 1], ['b', 2]])
size(clear(two)) === 0
remove
Alias for Map.delete
import { of, remove, size } from 'cartographic'
const two = of([['a', 1], ['b', 2]])
remove('a', two)
size(two) === 1
forEach
Curried tacit Map.forEach
, taking the iteration function first
import { of, forEach } from 'cartographic'
const two = of([['a', 1], ['b', 2]])
forEach((value, key) => console.log(`${key}-${value}`))
// prints
// a-1
// b-2
get
Curried tacit Map.get
, taking the key first
import {of, get} from 'cartographic'
const two = of([['a', 1], ['b', 2]])
get('a', two) // 1
has
Curried tacit Map.has
, taking the key first
import {of, has} from 'cartographic'
const two = of([['a', 1], ['b', 2]])
has('a', two) // true
has('sense', two) // false
set
Curried tacit Map.set
, taking the key, then the value, then the Map
import {of, set, get} from 'cartographic'
const two = of([['a', 1], ['b', 2]])
set('c', 3)
console.log(get('c', two)) // 3
map
Curried tacit form of forEach
which always returns a value.
Takes the transformation function first. Function receives [key, value]
as parameter.
import {of, map} from 'cartographic'
const two = of([['a', 1], ['b', 2]])
console.log(map(([k, v]) => `${k}${v}`)) // ['a1', 'b2']
toEntries
Alias for Map.prototype.entries()
Returns an iterator
toKeys
Alias for Map.prototype.keys()
Returns an iterator
toValues
Alias for Map.prototype.values()
Returns an iterator