# extra-map

• Version 3.1.15
• Published
• 80.6 kB
• No dependencies

## Install

``npm i extra-map``
``yarn add extra-map``
``pnpm add extra-map``

## Overview

A group of functions for working with Maps.

## Functions

### functioncartesianProduct

``cartesianProduct: <K, V, W = Map<K, V>>(    xs: Map<K, V>[],    fm?: MapFunction<number, Map<K, V>, Map<K, V> | W> | null) => IterableIterator<Map<K, V> | W>;``
• List cartesian product of maps. [📘](https://github.com/nodef/extra-map/wiki/cartesianProduct)

maps

#### Parameter fm

map function (vs, i)

#### Returns

x₀ × x₁ × ... = {{[k₀, v₀], [k₁, v₁], ...} | [k₀, v₀] ∈ x₀, [k₁, v₁] ∈ x₁, ...]}

### functionchunk

``chunk: <K, V>(x: Map<K, V>, n?: number, s?: number) => Map<K, V>[];``
• Break map into chunks of given size. [📘](https://github.com/nodef/extra-map/wiki/chunk)

a map

#### Parameter n

chunk size [1]

#### Parameter s

chunk step [n]

#### Returns

[x[0..n], x[s..s+n], x[2s..2s+n], ...]

### functioncompare

``compare: <K, V, W = V>(    x: Map<K, V>,    y: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => number;``
• Compare two maps. [📘](https://github.com/nodef/extra-map/wiki/compare)

a map

another map

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

x=y: 0, otherwise: -ve/+ve

### functionconcat

``concat: <K, V>(...xs: Entries<K, V>[]) => Map<K, V>;``
• Append entries from maps, preferring last. [📘](https://github.com/nodef/extra-map/wiki/concat)

maps

#### Returns

x₀ ∪ x₁ ∪ ... | [x₀, x₁, ...] = xs

### functionconcat\$

``concat\$: <K, V>(x: Map<K, V>, ...ys: Entries<K, V>[]) => Map<K, V>;``
• Append entries from maps, preferring last. [📘](https://github.com/nodef/extra-map/wiki/concat\$)

#### Parameter x

a map (updated)

other maps

#### Returns

x = x ∪ y₀ ∪ y₁ ∪ ... | [y₀, y₁, ...] = ys

### functioncount

``count: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => number;``
• Count values which satisfy a test. [📘](https://github.com/nodef/extra-map/wiki/count)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

Σtᵢ | tᵢ = 1 if ft(vᵢ) else 0; [kᵢ, vᵢ] ∈ x

### functioncountAs

``countAs: <K, V, W = V>(    x: Map<K, V>,    fm?: MapFunction<K, V, V | W> | null) => Map<V | W, number>;``
• Count occurrences of values. [📘](https://github.com/nodef/extra-map/wiki/countAs)

a map

#### Parameter fm

map function (v, k, x)

#### Returns

Map {value ⇒ count}

### functiondifference

``difference: <K, V>(x: Entries<K, V>, y: Entries<K, V>) => Map<K, V>;``
• Obtain entries not present in another map. [📘](https://github.com/nodef/extra-map/wiki/difference)

a map

another map

#### Returns

x - y = {[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x, [kᵢ, *] ∉ y}

### functiondifference\$

``difference\$: <K, V>(x: Map<K, V>, y: Entries<K, V>) => Map<K, V>;``
• Obtain entries not present in another map. [📘](https://github.com/nodef/extra-map/wiki/difference\$)

#### Parameter x

a map (updated)

another map

#### Returns

x = x - y = {[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x, [kᵢ, *] ∉ y}

### functiondrop

``drop: <K, V>(x: Map<K, V>, n?: number) => Map<K, V>;``
• Remove first n entries (default order). [📘](https://github.com/nodef/extra-map/wiki/drop)

a map

#### Parameter n

number of entries [1]

#### Returns

{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...} | [kᵢ, vᵢ] ∈ x and |{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...}| ≤ max(|x| - n, 0)

### functiondrop\$

``drop\$: <K, V>(x: Map<K, V>, n?: number) => Map<K, V>;``
• Remove first n entries (default order). [📘](https://github.com/nodef/extra-map/wiki/drop\$)

#### Parameter x

a map (updated)

#### Parameter n

number of entries [1]

#### Returns

x = {[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...} | [kᵢ, vᵢ] ∈ x and |{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...}| ≤ max(|x| - n, 0)

### functionentries

``entries: <K, V>(x: Map<K, V>) => IterableIterator<[K, V]>;``
• List all key-value pairs. [📘](https://github.com/nodef/extra-map/wiki/entries)

a map

#### Returns

[k₀, v₀], [k₁, v₁], ... | [kᵢ, vᵢ] ∈ x

### functionentry

``entry: <K, V>(x: Entries<K, V>, fr?: ReadFunction<number>) => [K, V];``
• Pick an arbitrary entry. [📘](https://github.com/nodef/extra-map/wiki/randomEntry)

a map

#### Parameter fr

random number generator ([0, 1))

#### Returns

[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x

### functionevery

``every: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => boolean;``
• Check if all values satisfy a test. [📘](https://github.com/nodef/extra-map/wiki/every)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

true if ft(vᵢ) = true for all [kᵢ, vᵢ] ∈ x

### functionfilter

``filter: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => Map<K, V>;``
• Keep entries which pass a test. [📘](https://github.com/nodef/extra-map/wiki/filter)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

{[k₀, v₀], [k₁, v₁], ...} | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x

### functionfilter\$

``filter\$: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => Map<K, V>;``
• Keep entries which pass a test. [📘](https://github.com/nodef/extra-map/wiki/filter\$)

#### Parameter x

an map (updated)

#### Parameter ft

test function (v, k, x)

#### Returns

x = {[k₀, v₀], [k₁, v₁], ...} | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x

### functionfilterAt

``filterAt: <K, V>(x: Map<K, V>, ks: K[]) => Map<K, V>;``
• Keep values at given keys. [📘](https://github.com/nodef/extra-map/wiki/filterAt)

a map

keys

#### Returns

{[k₀, v₀], [k₁, v₁], ...} | kᵢ ∈ ks; [kᵢ, vᵢ] ∈ x

### functionfilterAt\$

``filterAt\$: <K, V>(x: Map<K, V>, ks: K[]) => Map<K, V>;``
• Keep values at given keys. [📘](https://github.com/nodef/extra-map/wiki/filterAt\$)

#### Parameter x

a map (updated)

keys

#### Returns

x = {[k₀, v₀], [k₁, v₁], ...} | kᵢ ∈ ks; [kᵢ, vᵢ] ∈ x

### functionfind

``find: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => V;``
• Find first value passing a test (default order). [📘](https://github.com/nodef/extra-map/wiki/find)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

first v | ft(v) = true; [k, v] ∈ x

### functionfindAll

``findAll: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => V[];``
• Find values passing a test. [📘](https://github.com/nodef/extra-map/wiki/findAll)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

[v₀, v₁, ...] | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x

### functionflat

``flat: <K>(    x: Map<K, any>,    n?: number,    fm?: MapFunction<K, any, any> | null,    ft?: TestFunction<K, any> | null) => Map<K, any>;``
• Flatten nested map to given depth. [📘](https://github.com/nodef/extra-map/wiki/flat)

a nested map

#### Parameter n

maximum depth [-1 ⇒ all]

#### Parameter fm

map function (v, k, x)

#### Parameter ft

test function for flatten (v, k, x) [is]

flat map

### functionflatMap

``flatMap: <K>(    x: Map<K, any>,    fm?: MapFunction<K, any, any> | null,    ft?: TestFunction<K, any> | null) => Map<K, any>;``
• Flatten nested map, based on map function. [📘](https://github.com/nodef/extra-map/wiki/flatMap)

a nested map

#### Parameter fm

map function (v, k, x)

#### Parameter ft

test function for flatten (v, k, x) [is]

flat map

### functionforEach

``forEach: <K, V>(x: Map<K, V>, fp: ProcessFunction<K, V>) => void;``
• Call a function for each value. [📘](https://github.com/nodef/extra-map/wiki/forEach)

a map

#### Parameter fp

process function (v, k, x)

### functionfrom

``from: <K, V>(x: Entries<K, V>) => Map<K, V>;``
• Convert entries to map. [📘](https://github.com/nodef/extra-map/wiki/from)

entries

x as map

### functionfrom\$

``from\$: <K, V>(x: Entries<K, V>) => Map<K, V>;``
• Convert entries to map. [📘](https://github.com/nodef/extra-map/wiki/from\$)

#### Parameter x

entries (updateable is map!)

x as map

### functionfromEntries

``fromEntries: <K, V>(x: Entries<K, V>) => Map<K, V>;``
• Convert entries to map. [📘](https://github.com/nodef/extra-map/wiki/from)

entries

x as map

### functionfromEntries\$

``fromEntries\$: <K, V>(x: Entries<K, V>) => Map<K, V>;``
• Convert entries to map. [📘](https://github.com/nodef/extra-map/wiki/from\$)

#### Parameter x

entries (updateable is map!)

x as map

### functionfromKeys

``fromKeys: <K, V = K>(    x: Iterable<K>,    fm?: MapFunction\$1<K, K | V> | null) => Map<K, K | V>;``
• Create a map from keys. [📘](https://github.com/nodef/extra-map/wiki/fromKeys)

keys

#### Parameter fm

map function for values (v, i, x)

x as map

### functionfromLists

``fromLists: <K, V>(x: Lists<K, V>) => Map<K, V>;``
• Convert lists to map. [📘](https://github.com/nodef/extra-map/wiki/fromLists)

#### Parameter x

lists, i.e. [keys, values]

x as map

### functionfromValues

``fromValues: <V, K = V>(    x: Iterable<V>,    fm?: MapFunction\$1<V, V | K> | null) => Map<V | K, V>;``
• Create a map from values. [📘](https://github.com/nodef/extra-map/wiki/fromValues)

values

#### Parameter fm

map function for keys (v, i, x)

x as map

### functionget

``get: <K, V>(x: Map<K, V>, k: K) => V;``
• Get value at key. [📘](https://github.com/nodef/extra-map/wiki/get)

a map

key

x[k]

### functiongetAll

``getAll: <K, V>(x: Map<K, V>, ks: K[]) => V[];``
• Get values at keys. [📘](https://github.com/nodef/extra-map/wiki/getAll)

a map

keys

#### Returns

[x[k₀], x[k₁], ...] | [k₀, k₁, ...] = ks

### functiongetPath

``getPath: <K>(x: Map<K, any>, p: K[]) => any;``
• Get value at path in a nested map. [📘](https://github.com/nodef/extra-map/wiki/getPath)

a nested map

path

#### Returns

x[k₀][k₁][...] | [k₀, k₁, ...] = p

### functionhas

``has: <K, V>(x: Map<K, V>, k: K) => boolean;``
• Check if map has a key. [📘](https://github.com/nodef/extra-map/wiki/has)

a map

search key

[k, *] ∈ x?

### functionhasEntry

``hasEntry: <K, V, W = V>(    x: Map<K, V>,    e: [K, V],    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => boolean;``
• Check if map has an entry. [📘](https://github.com/nodef/extra-map/wiki/hasEntry)

a map

#### Parameter e

search entry ([k, v])

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

[k, v] ∈ x? | [k, v] = e

``hasKey: <K, V>(x: Map<K, V>, k: K) => boolean;``
• Check if map has a key. [📘](https://github.com/nodef/extra-map/wiki/has)

a map

search key

[k, *] ∈ x?

### functionhasPath

``hasPath: <K>(x: Map<K, any>, p: K[]) => boolean;``
• Check if nested map has a path. [📘](https://github.com/nodef/extra-map/wiki/hasPath)

a nested map

path

#### Returns

x[k₀][k₁][...] exists? | [k₀, k₁, ...] = p

### functionhasSubset

``hasSubset: <K, V, W = V>(    x: Map<K, V>,    y: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => boolean;``
• Check if map has a subset. [📘](https://github.com/nodef/extra-map/wiki/hasSubset)

a map

#### Parameter y

search subset

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

y ⊆ x?

### functionhasValue

``hasValue: <K, V, W = V>(    x: Map<K, V>,    v: V,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => boolean;``
• Check if map has a value. [📘](https://github.com/nodef/extra-map/wiki/hasValue)

a map

search value

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

[*, v] ∈ x?

``head: <K, V>(x: Entries<K, V>, ed?: [K, V]) => [K, V];``
• Get first entry from map (default order). [📘](https://github.com/nodef/extra-map/wiki/head)

a map

#### Parameter ed

default entry

#### Returns

[k₀, v₀] if x ≠ Φ else ed | [k₀, v₀] ∈ x

### functionintersection

``intersection: <K, V>(    x: Map<K, V>,    y: Entries<K, V>,    fc?: CombineFunction<V> | null) => Map<K, V>;``
• Obtain entries present in both maps. [📘](https://github.com/nodef/extra-map/wiki/intersection)

a map

another map

#### Parameter fc

combine function (a, b)

#### Returns

x ∩ y = {[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x and [kᵢ, vᵢ] ∈ y}

### functionintersection\$

``intersection\$: <K, V>(    x: Map<K, V>,    y: Map<K, V>,    fc?: CombineFunction<V> | null) => Map<K, V>;``
• Obtain entries present in both maps. [📘](https://github.com/nodef/extra-map/wiki/intersection\$)

#### Parameter x

a map (updated)

another map

#### Parameter fc

combine function (a, b)

#### Returns

x = x ∩ y = {[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x and [kᵢ, vᵢ] ∈ y}

### functionintersectionKeys

``intersectionKeys: <K, V>(...xs: Map<K, V>[]) => Set<K>;``
• Obtain keys present in all maps. [📘](https://github.com/nodef/extra-map/wiki/intersectionKeys)

maps

#### Returns

[k₀, k₁, ...] | [kᵢ, vᵢ] ∈ x₀ ∩ x₁, ...; [x₀, x₁, ...] = xs

### functionis

``is: (v: any) => v is Map<any, any>;``
• Check if value is a map. [📘](https://github.com/nodef/extra-map/wiki/is)

value

v is a map?

### functionisDisjoint

``isDisjoint: <K, V>(x: Map<K, V>, y: Entries<K, V>) => boolean;``
• Check if maps have no common keys. [📘](https://github.com/nodef/extra-map/wiki/isDisjoint)

a map

another map

x ∩ y = Φ?

### functionisEmpty

``isEmpty: <K, V>(x: Map<K, V>) => boolean;``
• Check if a map is empty. [📘](https://github.com/nodef/extra-map/wiki/isEmpty)

a map

|x| = 0?

### functionisEqual

``isEqual: <K, V, W = V>(    x: Map<K, V>,    y: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => boolean;``
• Check if two maps are equal. [📘](https://github.com/nodef/extra-map/wiki/isEqual)

a map

another map

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

x = y?

### functionjoin

``join: <K, V>(x: Entries<K, V>, sep?: string, asc?: string) => string;``
• Join entries together into a string. [📘](https://github.com/nodef/extra-map/wiki/join)

a map

#### Parameter sep

separator [,]

#### Parameter asc

associator [=]

#### Returns

"\${k₀}=\${v₀},\${k₁}=\${v₁}..." | [kᵢ, vᵢ] ∈ x

### functionkey

``key: <K, V>(x: Map<K, V>, fr?: ReadFunction<number>) => K;``
• Pick an arbitrary key. [📘](https://github.com/nodef/extra-map/wiki/randomKey)

a map

#### Parameter fr

random number generator ([0, 1))

#### Returns

kᵢ | [kᵢ, vᵢ] ∈ x

### functionkeys

``keys: <K, V>(x: Map<K, V>) => IterableIterator<K>;``
• List all keys. [📘](https://github.com/nodef/extra-map/wiki/keys)

a map

#### Returns

k₀, k₁, ... | [kᵢ, vᵢ] ∈ x

### functionlength

``length: <K, V>(x: Map<K, V>) => number;``
• Find the size of a map. [📘](https://github.com/nodef/extra-map/wiki/size)

a map

|x|

### functionmap

``map: <K, V, W = V>(x: Map<K, V>, fm: MapFunction<K, V, V | W>) => Map<K, V | W>;``
• Transform values of a map. [📘](https://github.com/nodef/extra-map/wiki/map)

a map

#### Parameter fm

map function (v, k, x)

#### Returns

{[k₀, fm(v₀)], [k₁, fm(v₁)], ...} | [kᵢ, vᵢ] ∈ x

### functionmap\$

``map\$: <K, V>(x: Map<K, V>, fm: MapFunction<K, V, V>) => Map<K, V>;``
• Transform values of a map. [📘](https://github.com/nodef/extra-map/wiki/map\$)

#### Parameter x

a map (updated)

#### Parameter fm

map function (v, k, x)

#### Returns

x = {[k₀, fm(v₀)], [k₁, fm(v₁)], ...} | [kᵢ, vᵢ] ∈ x

### functionmax

``max: <K, V, W = V>(    x: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => V;``
• Find largest value. [📘](https://github.com/nodef/extra-map/wiki/max)

a map

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

v | v ≥ vᵢ; [kᵢ, vᵢ] ∈ x

### functionmaxEntry

``maxEntry: <K, V, W = V>(    x: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => [K, V];``
• Find largest entry. [📘](https://github.com/nodef/extra-map/wiki/maxEntry)

a map

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

[max_key, max_value]

### functionmin

``min: <K, V, W = V>(    x: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => V;``
• Find smallest value. [📘](https://github.com/nodef/extra-map/wiki/min)

a map

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

v | v ≤ vᵢ; [kᵢ, vᵢ] ∈ x

### functionminEntry

``minEntry: <K, V, W = V>(    x: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => [K, V];``
• Find smallest entry. [📘](https://github.com/nodef/extra-map/wiki/minEntry)

a map

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

[min_key, min_value]

### functionpartition

``partition: <K, V>(    x: Map<K, V>,    ft: TestFunction<K, V>) => [Map<K, V>, Map<K, V>];``
• Segregate entries by test result. [📘](https://github.com/nodef/extra-map/wiki/partition)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

[satisfies, doesnt]

### functionpartitionAs

``partitionAs: <K, V, W = V>(    x: Map<K, V>,    fm: MapFunction<K, V, V | W>) => Map<V | W, Map<K, V>>;``
• Segregate entries by similarity. [📘](https://github.com/nodef/extra-map/wiki/partitionAs)

a map

#### Parameter fm

map function (v, k, x)

#### Returns

Map {key ⇒ values}

### functionrandomEntry

``randomEntry: <K, V>(x: Entries<K, V>, fr?: ReadFunction<number>) => [K, V];``
• Pick an arbitrary entry. [📘](https://github.com/nodef/extra-map/wiki/randomEntry)

a map

#### Parameter fr

random number generator ([0, 1))

#### Returns

[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x

### functionrandomKey

``randomKey: <K, V>(x: Map<K, V>, fr?: ReadFunction<number>) => K;``
• Pick an arbitrary key. [📘](https://github.com/nodef/extra-map/wiki/randomKey)

a map

#### Parameter fr

random number generator ([0, 1))

#### Returns

kᵢ | [kᵢ, vᵢ] ∈ x

### functionrandomSubset

``randomSubset: <K, V>(    x: Map<K, V>,    n?: number,    fr?: ReadFunction<number> | null) => Map<K, V>;``
• Pick an arbitrary subset. [📘](https://github.com/nodef/extra-map/wiki/randomSubset)

a map

#### Parameter n

number of entries [-1 ⇒ any]

#### Parameter fr

random number generator ([0, 1))

#### Returns

{[kᵢ, vᵢ], [kⱼ, vⱼ], ...} | [kᵢ, vᵢ], [kⱼ, vⱼ], ... ∈ x; |{[kᵢ, vᵢ], [kⱼ, vⱼ], ...}| = |x| if n<0 else n

### functionrange

``range: <K, V, W = V>(    x: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => [V, V];``
• Find smallest and largest values. [📘](https://github.com/nodef/extra-map/wiki/range)

a map

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

[min_value, max_value]

### functionrangeEntries

``rangeEntries: <K, V, W = V>(    x: Map<K, V>,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => [[K, V], [K, V]];``
• Find smallest and largest entries. [📘](https://github.com/nodef/extra-map/wiki/rangeEntries)

a map

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

[min_entry, max_entry]

### functionreduce

``reduce: <K, V, W = V>(    x: Map<K, V>,    fr: ReduceFunction<K, V, V | W>,    acc?: V | W) => V | W;``
• Reduce values of set to a single value. [📘](https://github.com/nodef/extra-map/wiki/reduce)

a map

#### Parameter fr

reduce function (acc, v, k, x)

#### Parameter acc

initial value

#### Returns

fr(fr(acc, v₀), v₁)... | fr(acc, v₀) = v₀ if acc not given

### functionreject

``reject: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => Map<K, V>;``
• Discard entries which pass a test. [📘](https://github.com/nodef/extra-map/wiki/reject)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

{[k₀, v₀], [k₁, v₁], ...} | ft(vᵢ) = false; [kᵢ, vᵢ] ∈ x

### functionreject\$

``reject\$: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => Map<K, V>;``
• Discard entries which pass a test. [📘](https://github.com/nodef/extra-map/wiki/reject\$)

#### Parameter x

a map (updated)

#### Parameter ft

test function (v, k, x)

#### Returns

x = {[k₀, v₀], [k₁, v₁], ...} | ft(vᵢ) = false; [kᵢ, vᵢ] ∈ x

### functionrejectAt

``rejectAt: <K, V>(x: Map<K, V>, ks: K[]) => Map<K, V>;``
• Discard values at given keys. [📘](https://github.com/nodef/extra-map/wiki/rejectAt)

a map

keys

#### Returns

{[k₀, v₀], [k₁, v₁], ...} | kᵢ ∉ ks; [kᵢ, vᵢ] ∈ x

### functionrejectAt\$

``rejectAt\$: <K, V>(x: Map<K, V>, ks: K[]) => Map<K, V>;``
• Discard values at given keys. [📘](https://github.com/nodef/extra-map/wiki/rejectAt\$)

#### Parameter x

a map (updated)

keys

#### Returns

x = {[k₀, v₀], [k₁, v₁], ...} | kᵢ ∉ ks; [kᵢ, vᵢ] ∈ x

### functionremove

``remove: <K, V>(x: Entries<K, V>, k: K) => Map<K, V>;``
• Remove value at key. [📘](https://github.com/nodef/extra-map/wiki/remove)

a map

key

x \: [k]

### functionremove\$

``remove\$: <K, V>(x: Map<K, V>, k: K) => Map<K, V>;``
• Remove value at key. [📘](https://github.com/nodef/extra-map/wiki/remove\$)

#### Parameter x

a map (updated)

key

x = x \: [k]

### functionremovePath\$

``removePath\$: <K>(x: Map<K, any>, p: K[]) => Map<K, any>;``
• Remove value at path in a nested map. [📘](https://github.com/nodef/extra-map/wiki/removePath\$)

#### Parameter x

a nested map (updated)

path

#### Returns

x = x \: [k₀][k₁][...] | [k₀, k₁, ...] = p

``search: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => K;``
• Find key of an entry passing a test. [📘](https://github.com/nodef/extra-map/wiki/search)

a map

#### Parameter ft

test function (v, k, x)

key of entry

### functionsearchAll

``searchAll: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => K[];``
• Find keys of entries passing a test. [📘](https://github.com/nodef/extra-map/wiki/searchAll)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

keys of entries

### functionsearchValue

``searchValue: <K, V, W = V>(    x: Map<K, V>,    v: V,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => K;``
• Find a key with given value. [📘](https://github.com/nodef/extra-map/wiki/searchValue)

a map

search value

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

key of value

### functionsearchValueAll

``searchValueAll: <K, V, W = V>(    x: Map<K, V>,    v: V,    fc?: CompareFunction<V | W> | null,    fm?: MapFunction<K, V, V | W> | null) => K[];``
• Find keys with given value. [📘](https://github.com/nodef/extra-map/wiki/searchValueAll)

a map

search value

#### Parameter fc

compare function (a, b)

#### Parameter fm

map function (v, k, x)

#### Returns

keys of value

### functionset

``set: <K, V>(x: Entries<K, V>, k: K, v: V) => Map<K, V>;``
• Set value at key. [📘](https://github.com/nodef/extra-map/wiki/set)

a map

key

value

#### Returns

x' | x' = x; x'[k] = v

### functionset\$

``set\$: <K, V>(x: Map<K, V>, k: K, v: V) => Map<K, V>;``
• Set value at key. [📘](https://github.com/nodef/extra-map/wiki/set\$)

#### Parameter x

a map (updated)

key

value

x | x[k] = v

### functionsetPath\$

``setPath\$: <K>(x: Map<K, any>, p: K[], v: any) => Map<K, any>;``
• Set value at path in a nested map. [📘](https://github.com/nodef/extra-map/wiki/setPath\$)

#### Parameter x

a nested map (updated)

path

value

#### Returns

x | x[k₀][k₁][...] = v; [k₀, k₁, ...] = p

### functionsize

``size: <K, V>(x: Map<K, V>) => number;``
• Find the size of a map. [📘](https://github.com/nodef/extra-map/wiki/size)

a map

|x|

### functionsome

``some: <K, V>(x: Map<K, V>, ft: TestFunction<K, V>) => boolean;``
• Check if any value satisfies a test. [📘](https://github.com/nodef/extra-map/wiki/some)

a map

#### Parameter ft

test function (v, k, x)

#### Returns

true if ft(vᵢ) = true for some [kᵢ, vᵢ] ∈ x

### functionsubset

``subset: <K, V>(    x: Map<K, V>,    n?: number,    fr?: ReadFunction<number> | null) => Map<K, V>;``
• Pick an arbitrary subset. [📘](https://github.com/nodef/extra-map/wiki/randomSubset)

a map

#### Parameter n

number of entries [-1 ⇒ any]

#### Parameter fr

random number generator ([0, 1))

#### Returns

{[kᵢ, vᵢ], [kⱼ, vⱼ], ...} | [kᵢ, vᵢ], [kⱼ, vⱼ], ... ∈ x; |{[kᵢ, vᵢ], [kⱼ, vⱼ], ...}| = |x| if n<0 else n

### functionsubsets

``subsets: <K, V>(x: Map<K, V>, n?: number) => IterableIterator<Map<K, V>>;``
• List all possible subsets. [📘](https://github.com/nodef/extra-map/wiki/subsets)

a map

#### Parameter n

number of entries [-1 ⇒ any]

#### Returns

entries selected by bit from 0..2^|x| if n<0; only of length n otherwise

### functionswap

``swap: <K, V>(x: Entries<K, V>, k: K, l: K) => Map<K, V>;``
• Exchange two values. [📘](https://github.com/nodef/extra-map/wiki/swap)

a map

a key

another key

#### Returns

x' | x' = x; x'[k] = x[l]; x'[l] = x[k]

### functionswap\$

``swap\$: <K, V>(x: Map<K, V>, k: K, l: K) => Map<K, V>;``
• Exchange two values. [📘](https://github.com/nodef/extra-map/wiki/swap\$)

#### Parameter x

a map (updated)

a key

another key

#### Returns

x | x[i] ↔ x[j]

### functionsymmetricDifference

``symmetricDifference: <K, V>(x: Entries<K, V>, y: Entries<K, V>) => Map<K, V>;``
• Obtain entries not present in both maps. [📘](https://github.com/nodef/extra-map/wiki/symmetricDifference)

a map

another map

x-y ∪ y-x

### functionsymmetricDifference\$

``symmetricDifference\$: <K, V>(x: Map<K, V>, y: Entries<K, V>) => Map<K, V>;``
• Obtain entries not present in both maps. [📘](https://github.com/nodef/extra-map/wiki/symmetricDifference\$)

#### Parameter x

a map (updated)

another map

#### Returns

x = x-y ∪ y-x

### functiontail

``tail: <K, V>(x: Map<K, V>) => Map<K, V>;``
• Get a map without its first entry (default order). [📘](https://github.com/nodef/extra-map/wiki/tail)

a map

#### Returns

x \ {[k₀, v₀]} if x ≠ Φ else x | [k₀, v₀] ∈ x

### functiontake

``take: <K, V>(x: Map<K, V>, n?: number) => Map<K, V>;``
• Keep first n entries only (default order). [📘](https://github.com/nodef/extra-map/wiki/take)

a map

#### Parameter n

number of entries [1]

#### Returns

{[k₀, v₀], [k₁, v₁], ...} | [kᵢ, vᵢ] ∈ x and |{[k₀, v₀], [k₁, v₁], ...}| ≤ n

### functiontake\$

``take\$: <K, V>(x: Map<K, V>, n?: number) => Map<K, V>;``
• Keep first n entries only (default order). [📘](https://github.com/nodef/extra-map/wiki/take\$)

#### Parameter x

a map (updated)

#### Parameter n

number of entries [1]

#### Returns

x = {[k₀, v₀], [k₁, v₁], ...} | [kᵢ, vᵢ] ∈ x and |{[k₀, v₀], [k₁, v₁], ...}| ≤ n

### functionunion

``union: <K, V>(    x: Entries<K, V>,    y: Entries<K, V>,    fc?: CombineFunction<V> | null) => Map<K, V>;``
• Obtain entries present in any map. [📘](https://github.com/nodef/extra-map/wiki/union)

a map

another map

#### Parameter fc

combine function (a, b)

#### Returns

x ∪ y = {[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x or [kᵢ, vᵢ] ∈ y}

### functionunion\$

``union\$: <K, V>(    x: Map<K, V>,    y: Entries<K, V>,    fc?: CombineFunction<V> | null) => Map<K, V>;``
• Obtain entries present in any map. [📘](https://github.com/nodef/extra-map/wiki/union\$)

#### Parameter x

a map (updated)

another map

#### Parameter fc

combine function (a, b)

#### Returns

x = x ∪ y = {[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x or [kᵢ, vᵢ] ∈ y}

### functionunionKeys

``unionKeys: <K, V>(...xs: Entries<K, V>[]) => Set<K>;``
• Obtain keys present in any map. [📘](https://github.com/nodef/extra-map/wiki/unionKeys)

maps

#### Returns

[k₀, k₁, ...] | [kᵢ, vᵢ] ∈ x₀ ∪ x₁, ...; [x₀, x₁, ...] = xs

### functionvalues

``values: <K, V>(x: Map<K, V>) => IterableIterator<V>;``
• List all values. [📘](https://github.com/nodef/extra-map/wiki/values)

a map

#### Returns

v₀, v₁, ... | [kᵢ, vᵢ] ∈ x

### functionzip

``zip: <K, V, W = V>(    xs: Map<K, V>[],    fm?: MapFunction<K, V[], V[] | W> | null,    fe?: EndFunction,    vd?: V) => Map<K, V[] | W>;``
• Combine matching entries from maps. [📘](https://github.com/nodef/extra-map/wiki/zip)

maps

#### Parameter fm

map function (vs, k)

#### Parameter fe

end function (dones) [array.some]

#### Parameter vd

default value

#### Returns

[fm([x₀[k₀], x₁[k₀], ...]), fm([x₀[k₁], x₁[k₁], ...]), ...]

## Type Aliases

### typeCombineFunction

``type CombineFunction<V> = (a: V, b: V) => V;``
• Handle combining of two values. [📘](https://github.com/nodef/extra-map/wiki/CombineFunction)

a value

#### Parameter b

another value

#### Returns

combined value

### typeCompareFunction

``type CompareFunction<V> = (a: V, b: V) => number;``
• Handle comparison of two values. [📘](https://github.com/nodef/extra-map/wiki/CompareFunction)

a value

#### Parameter b

another value

#### Returns

a<b: -ve, a=b: 0, a>b: +ve

### typeEndFunction

``type EndFunction = (dones: boolean[]) => boolean;``
• Handle ending of a combined map. [📘](https://github.com/nodef/extra-map/wiki/EndFunction)

#### Parameter dones

iᵗʰ map done?

#### Returns

combined map done?

### typeEntries

``type Entries<K, V> = Iterable<[K, V]>;``
• Entries is a list of key-value pairs, with unique keys. [📘](https://github.com/nodef/extra-map/wiki/Entries)

### typeLists

``type Lists<K, V> = [Iterable<K>, Iterable<V>];``
• Lists is a pair of key list and value list, with unique keys. [📘](https://github.com/nodef/extra-map/wiki/Lists)

### typeMapFunction

``type MapFunction<K, V, W> = (v: V, k: K, x: Map<K, V>) => W;``
• Handle transformation of a value to another. [📘](https://github.com/nodef/extra-map/wiki/MapFunction)

value in map

#### Parameter k

key of value in map

#### Parameter x

map containing the value

#### Returns

transformed value

### typeProcessFunction

``type ProcessFunction<K, V> = (v: V, k: K, x: Map<K, V>) => void;``
• Handle processing of values in a map. [📘](https://github.com/nodef/extra-map/wiki/ProcessFunction)

value in map

#### Parameter k

key of value in map

#### Parameter x

map containing the value

``type ReadFunction<V> = () => V;``

value

### typeReduceFunction

``type ReduceFunction<K, V, W> = (acc: W, v: V, k: K, x: Map<K, V>) => W;``
• Handle reduction of multiple values into a single value. [📘](https://github.com/nodef/extra-map/wiki/ReduceFunction)

#### Parameter acc

accumulator (temporary result)

value in map

#### Parameter k

key of value in map

#### Parameter x

map containing the value

#### Returns

reduced value

### typeTestFunction

``type TestFunction<K, V> = (v: V, k: K, x: Map<K, V>) => boolean;``
• Handle selection of values in a map. [📘](https://github.com/nodef/extra-map/wiki/TestFunction)

value in map

#### Parameter k

key of value in map

#### Parameter x

map containing the value

selected?

No dependencies.

## Peer Dependencies (0)

No peer dependencies.

You may also use Shields.io to create a custom badge linking to `https://www.jsdocs.io/package/extra-map`.
``[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/extra-map)``
``<a href="https://www.jsdocs.io/package/extra-map"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>``