import { MapFunction as MapFunction$1 } from 'extra-iterable';

/**
 * Entries is a list of key-value pairs, with unique keys.
 * [📘](https://github.com/nodef/extra-map/wiki/Entries)
 */
type Entries<K, V> = Iterable<[K, V]>;
/**
 * Lists is a pair of key list and value list, with unique keys.
 * [📘](https://github.com/nodef/extra-map/wiki/Lists)
 */
type Lists<K, V> = [Iterable<K>, Iterable<V>];
/**
 * Handle reading of a single value.
 * [📘](https://github.com/nodef/extra-map/wiki/ReadFunction)
 * @returns value
 */
type ReadFunction<V> = () => V;
/**
 * Handle combining of two values.
 * [📘](https://github.com/nodef/extra-map/wiki/CombineFunction)
 * @param a a value
 * @param b another value
 * @returns combined value
 */
type CombineFunction<V> = (a: V, b: V) => V;
/**
 * Handle comparison of two values.
 * [📘](https://github.com/nodef/extra-map/wiki/CompareFunction)
 * @param a a value
 * @param b another value
 * @returns a<b: -ve, a=b: 0, a>b: +ve
 */
type CompareFunction<V> = (a: V, b: V) => number;
/**
 * Handle processing of values in a map.
 * [📘](https://github.com/nodef/extra-map/wiki/ProcessFunction)
 * @param v value in map
 * @param k key of value in map
 * @param x map containing the value
 */
type ProcessFunction<K, V> = (v: V, k: K, x: Map<K, V>) => void;
/**
 * Handle selection of values in a map.
 * [📘](https://github.com/nodef/extra-map/wiki/TestFunction)
 * @param v value in map
 * @param k key of value in map
 * @param x map containing the value
 * @returns selected?
 */
type TestFunction<K, V> = (v: V, k: K, x: Map<K, V>) => boolean;
/**
 * Handle transformation of a value to another.
 * [📘](https://github.com/nodef/extra-map/wiki/MapFunction)
 * @param v value in map
 * @param k key of value in map
 * @param x map containing the value
 * @returns transformed value
 */
type MapFunction<K, V, 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)
 * @param acc accumulator (temporary result)
 * @param v value in map
 * @param k key of value in map
 * @param x map containing the value
 * @returns reduced value
 */
type ReduceFunction<K, V, W> = (acc: W, v: V, k: K, x: Map<K, V>) => W;
/**
 * Handle ending of a combined map.
 * [📘](https://github.com/nodef/extra-map/wiki/EndFunction)
 * @param dones iᵗʰ map done?
 * @returns combined map done?
 */
type EndFunction = (dones: boolean[]) => boolean;
/**
 * Check if value is a map.
 * [📘](https://github.com/nodef/extra-map/wiki/is)
 * @param v value
 * @returns v is a map?
 */
declare function is(v: any): v is Map<any, any>;
/**
 * List all keys.
 * [📘](https://github.com/nodef/extra-map/wiki/keys)
 * @param x a map
 * @returns k₀, k₁, ... | [kᵢ, vᵢ] ∈ x
 */
declare function keys<K, V>(x: Map<K, V>): IterableIterator<K>;
/**
 * List all values.
 * [📘](https://github.com/nodef/extra-map/wiki/values)
 * @param x a map
 * @returns v₀, v₁, ... | [kᵢ, vᵢ] ∈ x
 */
declare function values<K, V>(x: Map<K, V>): IterableIterator<V>;
/**
 * List all key-value pairs.
 * [📘](https://github.com/nodef/extra-map/wiki/entries)
 * @param x a map
 * @returns [k₀, v₀], [k₁, v₁], ... | [kᵢ, vᵢ] ∈ x
 */
declare function entries<K, V>(x: Map<K, V>): IterableIterator<[K, V]>;
/**
 * Convert entries to map.
 * [📘](https://github.com/nodef/extra-map/wiki/from)
 * @param x entries
 * @returns x as map
 */
declare function from<K, V>(x: Entries<K, V>): Map<K, V>;

/**
 * Convert entries to map.
 * [📘](https://github.com/nodef/extra-map/wiki/from$)
 * @param x entries (updateable is map!)
 * @returns x as map
 */
declare function from$<K, V>(x: Entries<K, V>): Map<K, V>;

/**
 * Convert lists to map.
 * [📘](https://github.com/nodef/extra-map/wiki/fromLists)
 * @param x lists, i.e. [keys, values]
 * @returns x as map
 */
declare function fromLists<K, V>(x: Lists<K, V>): Map<K, V>;
/**
 * Create a map from keys.
 * [📘](https://github.com/nodef/extra-map/wiki/fromKeys)
 * @param x keys
 * @param fm map function for values (v, i, x)
 * @returns x as map
 */
declare function fromKeys<K, V = K>(x: Iterable<K>, fm?: MapFunction$1<K, K | V> | null): Map<K, K | V>;
/**
 * Create a map from values.
 * [📘](https://github.com/nodef/extra-map/wiki/fromValues)
 * @param x values
 * @param fm map function for keys (v, i, x)
 * @returns x as map
 */
declare function fromValues<V, K = V>(x: Iterable<V>, fm?: MapFunction$1<V, V | K> | null): Map<V | K, V>;
/**
 * Compare two maps.
 * [📘](https://github.com/nodef/extra-map/wiki/compare)
 * @param x a map
 * @param y another map
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns x=y: 0, otherwise: -ve/+ve
 */
declare function 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;
/**
 * Check if two maps are equal.
 * [📘](https://github.com/nodef/extra-map/wiki/isEqual)
 * @param x a map
 * @param y another map
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns x = y?
 */
declare function 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;
/**
 * Find the size of a map.
 * [📘](https://github.com/nodef/extra-map/wiki/size)
 * @param x a map
 * @returns |x|
 */
declare function size<K, V>(x: Map<K, V>): number;

/**
 * Check if a map is empty.
 * [📘](https://github.com/nodef/extra-map/wiki/isEmpty)
 * @param x a map
 * @returns |x| = 0?
 */
declare function isEmpty<K, V>(x: Map<K, V>): boolean;
/**
 * Get value at key.
 * [📘](https://github.com/nodef/extra-map/wiki/get)
 * @param x a map
 * @param k key
 * @returns x[k]
 */
declare function get<K, V>(x: Map<K, V>, k: K): V;
/**
 * Get values at keys.
 * [📘](https://github.com/nodef/extra-map/wiki/getAll)
 * @param x a map
 * @param ks keys
 * @returns [x[k₀], x[k₁], ...] | [k₀, k₁, ...] = ks
 */
declare function getAll<K, V>(x: Map<K, V>, ks: K[]): V[];
/**
 * Get value at path in a nested map.
 * [📘](https://github.com/nodef/extra-map/wiki/getPath)
 * @param x a nested map
 * @param p path
 * @returns x[k₀][k₁][...] | [k₀, k₁, ...] = p
 */
declare function getPath<K>(x: Map<K, any>, p: K[]): any;
/**
 * Check if nested map has a path.
 * [📘](https://github.com/nodef/extra-map/wiki/hasPath)
 * @param x a nested map
 * @param p path
 * @returns x[k₀][k₁][...] exists? | [k₀, k₁, ...] = p
 */
declare function hasPath<K>(x: Map<K, any>, p: K[]): boolean;
/**
 * Set value at key.
 * [📘](https://github.com/nodef/extra-map/wiki/set)
 * @param x a map
 * @param k key
 * @param v value
 * @returns x' | x' = x; x'[k] = v
 */
declare function 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$)
 * @param x a map (updated)
 * @param k key
 * @param v value
 * @returns x | x[k] = v
 */
declare function set$<K, V>(x: Map<K, V>, k: K, v: V): Map<K, V>;
/**
 * Set value at path in a nested map.
 * [📘](https://github.com/nodef/extra-map/wiki/setPath$)
 * @param x a nested map (updated)
 * @param p path
 * @param v value
 * @returns x | x[k₀][k₁][...] = v; [k₀, k₁, ...] = p
 */
declare function setPath$<K>(x: Map<K, any>, p: K[], v: any): Map<K, any>;
/**
 * Exchange two values.
 * [📘](https://github.com/nodef/extra-map/wiki/swap)
 * @param x a map
 * @param k a key
 * @param l another key
 * @returns x' | x' = x; x'[k] = x[l]; x'[l] = x[k]
 */
declare function 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$)
 * @param x a map (updated)
 * @param k a key
 * @param l another key
 * @returns x | x[i] ↔ x[j]
 */
declare function swap$<K, V>(x: Map<K, V>, k: K, l: K): Map<K, V>;
/**
 * Remove value at key.
 * [📘](https://github.com/nodef/extra-map/wiki/remove)
 * @param x a map
 * @param k key
 * @returns x \\: [k]
 */
declare function remove<K, V>(x: Entries<K, V>, k: K): Map<K, V>;
/**
 * Remove value at key.
 * [📘](https://github.com/nodef/extra-map/wiki/remove$)
 * @param x a map (updated)
 * @param k key
 * @returns x = x \\: [k]
 */
declare function remove$<K, V>(x: Map<K, V>, k: K): Map<K, V>;
/**
 * Remove value at path in a nested map.
 * [📘](https://github.com/nodef/extra-map/wiki/removePath$)
 * @param x a nested map (updated)
 * @param p path
 * @returns x = x \\: [k₀][k₁][...] | [k₀, k₁, ...] = p
 */
declare function removePath$<K>(x: Map<K, any>, p: K[]): Map<K, any>;
/**
 * Count values which satisfy a test.
 * [📘](https://github.com/nodef/extra-map/wiki/count)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns Σtᵢ | tᵢ = 1 if ft(vᵢ) else 0; [kᵢ, vᵢ] ∈ x
 */
declare function count<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): number;
/**
 * Count occurrences of values.
 * [📘](https://github.com/nodef/extra-map/wiki/countAs)
 * @param x a map
 * @param fm map function (v, k, x)
 * @returns Map \{value ⇒ count\}
 */
declare function countAs<K, V, W = V>(x: Map<K, V>, fm?: MapFunction<K, V, V | W> | null): Map<V | W, number>;
/**
 * Find smallest value.
 * [📘](https://github.com/nodef/extra-map/wiki/min)
 * @param x a map
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns v | v ≤ vᵢ; [kᵢ, vᵢ] ∈ x
 */
declare function min<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): V;
/**
 * Find smallest entry.
 * [📘](https://github.com/nodef/extra-map/wiki/minEntry)
 * @param x a map
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns [min_key, min_value]
 */
declare function minEntry<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): [K, V];
/**
 * Find largest value.
 * [📘](https://github.com/nodef/extra-map/wiki/max)
 * @param x a map
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns v | v ≥ vᵢ; [kᵢ, vᵢ] ∈ x
 */
declare function max<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): V;
/**
 * Find largest entry.
 * [📘](https://github.com/nodef/extra-map/wiki/maxEntry)
 * @param x a map
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns [max_key, max_value]
 */
declare function maxEntry<K, V, W = V>(x: Map<K, V>, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): [K, V];
/**
 * Find smallest and largest values.
 * [📘](https://github.com/nodef/extra-map/wiki/range)
 * @param x a map
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns [min_value, max_value]
 */
declare function 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 entries.
 * [📘](https://github.com/nodef/extra-map/wiki/rangeEntries)
 * @param x a map
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns [min_entry, max_entry]
 */
declare function 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]];
/**
 * Get first entry from map (default order).
 * [📘](https://github.com/nodef/extra-map/wiki/head)
 * @param x a map
 * @param ed default entry
 * @returns [k₀, v₀] if x ≠ Φ else ed | [k₀, v₀] ∈ x
 */
declare function head<K, V>(x: Entries<K, V>, ed?: [K, V]): [K, V];
/**
 * Get a map without its first entry (default order).
 * [📘](https://github.com/nodef/extra-map/wiki/tail)
 * @param x a map
 * @returns x \\ \{[k₀, v₀]\} if x ≠ Φ else x | [k₀, v₀] ∈ x
 */
declare function tail<K, V>(x: Map<K, V>): Map<K, V>;
/**
 * Keep first n entries only (default order).
 * [📘](https://github.com/nodef/extra-map/wiki/take)
 * @param x a map
 * @param n number of entries [1]
 * @returns \{[k₀, v₀], [k₁, v₁], ...\} | [kᵢ, vᵢ] ∈ x and |\{[k₀, v₀], [k₁, v₁], ...\}| ≤ n
 */
declare function 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$)
 * @param x a map (updated)
 * @param n number of entries [1]
 * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | [kᵢ, vᵢ] ∈ x and |\{[k₀, v₀], [k₁, v₁], ...\}| ≤ n
 */
declare function take$<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)
 * @param x a map
 * @param n number of entries [1]
 * @returns \{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...\} | [kᵢ, vᵢ] ∈ x and |\{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...\}| ≤ max(|x| - n, 0)
 */
declare function 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$)
 * @param x a map (updated)
 * @param n number of entries [1]
 * @returns x = \{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...\} | [kᵢ, vᵢ] ∈ x and |\{[kₙ, vₙ], [kₙ₊₁, vₙ₊₁], ...\}| ≤ max(|x| - n, 0)
 */
declare function drop$<K, V>(x: Map<K, V>, n?: number): Map<K, V>;
/**
 * List all possible subsets.
 * [📘](https://github.com/nodef/extra-map/wiki/subsets)
 * @param x a map
 * @param n number of entries [-1 ⇒ any]
 * @returns entries selected by bit from 0..2^|x| if n<0; only of length n otherwise
 */
declare function subsets<K, V>(x: Map<K, V>, n?: number): IterableIterator<Map<K, V>>;
/**
 * Pick an arbitrary key.
 * [📘](https://github.com/nodef/extra-map/wiki/randomKey)
 * @param x a map
 * @param fr random number generator ([0, 1))
 * @returns kᵢ | [kᵢ, vᵢ] ∈ x
 */
declare function randomKey<K, V>(x: Map<K, V>, fr?: ReadFunction<number>): K;

/**
 * Pick an arbitrary entry.
 * [📘](https://github.com/nodef/extra-map/wiki/randomEntry)
 * @param x a map
 * @param fr random number generator ([0, 1))
 * @returns [kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x
 */
declare function randomEntry<K, V>(x: Entries<K, V>, fr?: ReadFunction<number>): [K, V];

/**
 * Pick an arbitrary subset.
 * [📘](https://github.com/nodef/extra-map/wiki/randomSubset)
 * @param x a map
 * @param n number of entries [-1 ⇒ any]
 * @param 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
 */
declare function randomSubset<K, V>(x: Map<K, V>, n?: number, fr?: ReadFunction<number> | null): Map<K, V>;

/**
 * Check if map has a key.
 * [📘](https://github.com/nodef/extra-map/wiki/has)
 * @param x a map
 * @param k search key
 * @returns [k, *] ∈ x?
 */
declare function has<K, V>(x: Map<K, V>, k: K): boolean;

/**
 * Check if map has a value.
 * [📘](https://github.com/nodef/extra-map/wiki/hasValue)
 * @param x a map
 * @param v search value
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns [*, v] ∈ x?
 */
declare function 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 an entry.
 * [📘](https://github.com/nodef/extra-map/wiki/hasEntry)
 * @param x a map
 * @param e search entry ([k, v])
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns [k, v] ∈ x? | [k, v] = e
 */
declare function 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 a subset.
 * [📘](https://github.com/nodef/extra-map/wiki/hasSubset)
 * @param x a map
 * @param y search subset
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns y ⊆ x?
 */
declare function 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;
/**
 * Find first value passing a test (default order).
 * [📘](https://github.com/nodef/extra-map/wiki/find)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns first v | ft(v) = true; [k, v] ∈ x
 */
declare function find<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): V;
/**
 * Find values passing a test.
 * [📘](https://github.com/nodef/extra-map/wiki/findAll)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns [v₀, v₁, ...] | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x
 */
declare function findAll<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): V[];
/**
 * Find key of an entry passing a test.
 * [📘](https://github.com/nodef/extra-map/wiki/search)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns key of entry
 */
declare function search<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)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns keys of entries
 */
declare function searchAll<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): K[];
/**
 * Find a key with given value.
 * [📘](https://github.com/nodef/extra-map/wiki/searchValue)
 * @param x a map
 * @param v search value
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns key of value
 */
declare function 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 keys with given value.
 * [📘](https://github.com/nodef/extra-map/wiki/searchValueAll)
 * @param x a map
 * @param v search value
 * @param fc compare function (a, b)
 * @param fm map function (v, k, x)
 * @returns keys of value
 */
declare function searchValueAll<K, V, W = V>(x: Map<K, V>, v: V, fc?: CompareFunction<V | W> | null, fm?: MapFunction<K, V, V | W> | null): K[];
/**
 * Call a function for each value.
 * [📘](https://github.com/nodef/extra-map/wiki/forEach)
 * @param x a map
 * @param fp process function (v, k, x)
 */
declare function forEach<K, V>(x: Map<K, V>, fp: ProcessFunction<K, V>): void;
/**
 * Check if any value satisfies a test.
 * [📘](https://github.com/nodef/extra-map/wiki/some)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns true if ft(vᵢ) = true for some [kᵢ, vᵢ] ∈ x
 */
declare function some<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)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns true if ft(vᵢ) = true for all [kᵢ, vᵢ] ∈ x
 */
declare function every<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): boolean;
/**
 * Transform values of a map.
 * [📘](https://github.com/nodef/extra-map/wiki/map)
 * @param x a map
 * @param fm map function (v, k, x)
 * @returns \{[k₀, fm(v₀)], [k₁, fm(v₁)], ...\} | [kᵢ, vᵢ] ∈ x
 */
declare function 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$)
 * @param x a map (updated)
 * @param fm map function (v, k, x)
 * @returns x = \{[k₀, fm(v₀)], [k₁, fm(v₁)], ...\} | [kᵢ, vᵢ] ∈ x
 */
declare function map$<K, V>(x: Map<K, V>, fm: MapFunction<K, V, V>): Map<K, V>;
/**
 * Reduce values of set to a single value.
 * [📘](https://github.com/nodef/extra-map/wiki/reduce)
 * @param x a map
 * @param fr reduce function (acc, v, k, x)
 * @param acc initial value
 * @returns fr(fr(acc, v₀), v₁)... | fr(acc, v₀) = v₀ if acc not given
 */
declare function reduce<K, V, W = V>(x: Map<K, V>, fr: ReduceFunction<K, V, V | W>, acc?: V | W): V | W;
/**
 * Keep entries which pass a test.
 * [📘](https://github.com/nodef/extra-map/wiki/filter)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns \{[k₀, v₀], [k₁, v₁], ...\} | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x
 */
declare function 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$)
 * @param x an map (updated)
 * @param ft test function (v, k, x)
 * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | ft(vᵢ) = true; [kᵢ, vᵢ] ∈ x
 */
declare function filter$<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): Map<K, V>;
/**
 * Keep values at given keys.
 * [📘](https://github.com/nodef/extra-map/wiki/filterAt)
 * @param x a map
 * @param ks keys
 * @returns \{[k₀, v₀], [k₁, v₁], ...\} | kᵢ ∈ ks; [kᵢ, vᵢ] ∈ x
 */
declare function 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$)
 * @param x a map (updated)
 * @param ks keys
 * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | kᵢ ∈ ks; [kᵢ, vᵢ] ∈ x
 */
declare function filterAt$<K, V>(x: Map<K, V>, ks: K[]): Map<K, V>;
/**
 * Discard entries which pass a test.
 * [📘](https://github.com/nodef/extra-map/wiki/reject)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns \{[k₀, v₀], [k₁, v₁], ...\} | ft(vᵢ) = false; [kᵢ, vᵢ] ∈ x
 */
declare function 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$)
 * @param x a map (updated)
 * @param ft test function (v, k, x)
 * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | ft(vᵢ) = false; [kᵢ, vᵢ] ∈ x
 */
declare function reject$<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): Map<K, V>;
/**
 * Discard values at given keys.
 * [📘](https://github.com/nodef/extra-map/wiki/rejectAt)
 * @param x a map
 * @param ks keys
 * @returns \{[k₀, v₀], [k₁, v₁], ...\} | kᵢ ∉ ks; [kᵢ, vᵢ] ∈ x
 */
declare function 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$)
 * @param x a map (updated)
 * @param ks keys
 * @returns x = \{[k₀, v₀], [k₁, v₁], ...\} | kᵢ ∉ ks; [kᵢ, vᵢ] ∈ x
 */
declare function rejectAt$<K, V>(x: Map<K, V>, ks: K[]): Map<K, V>;
/**
 * Flatten nested map to given depth.
 * [📘](https://github.com/nodef/extra-map/wiki/flat)
 * @param x a nested map
 * @param n maximum depth [-1 ⇒ all]
 * @param fm map function (v, k, x)
 * @param ft test function for flatten (v, k, x) [is]
 * @returns flat map
 */
declare function 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, based on map function.
 * [📘](https://github.com/nodef/extra-map/wiki/flatMap)
 * @param x a nested map
 * @param fm map function (v, k, x)
 * @param ft test function for flatten (v, k, x) [is]
 * @returns flat map
 */
declare function flatMap<K>(x: Map<K, any>, fm?: MapFunction<K, any, any> | null, ft?: TestFunction<K, any> | null): Map<K, any>;
/**
 * Combine matching entries from maps.
 * [📘](https://github.com/nodef/extra-map/wiki/zip)
 * @param xs maps
 * @param fm map function (vs, k)
 * @param fe end function (dones) [array.some]
 * @param vd default value
 * @returns [fm([x₀[k₀], x₁[k₀], ...]), fm([x₀[k₁], x₁[k₁], ...]), ...]
 */
declare function zip<K, V, W = V>(xs: Map<K, V>[], fm?: MapFunction<K, V[], V[] | W> | null, fe?: EndFunction, vd?: V): Map<K, V[] | W>;
/**
 * Segregate entries by test result.
 * [📘](https://github.com/nodef/extra-map/wiki/partition)
 * @param x a map
 * @param ft test function (v, k, x)
 * @returns [satisfies, doesnt]
 */
declare function partition<K, V>(x: Map<K, V>, ft: TestFunction<K, V>): [Map<K, V>, Map<K, V>];
/**
 * Segregate entries by similarity.
 * [📘](https://github.com/nodef/extra-map/wiki/partitionAs)
 * @param x a map
 * @param fm map function (v, k, x)
 * @returns Map \{key ⇒ values\}
 */
declare function partitionAs<K, V, W = V>(x: Map<K, V>, fm: MapFunction<K, V, V | W>): Map<V | W, Map<K, V>>;
/**
 * Break map into chunks of given size.
 * [📘](https://github.com/nodef/extra-map/wiki/chunk)
 * @param x a map
 * @param n chunk size [1]
 * @param s chunk step [n]
 * @returns [x[0..n], x[s..s+n], x[2s..2s+n], ...]
 */
declare function chunk<K, V>(x: Map<K, V>, n?: number, s?: number): Map<K, V>[];
/**
 * Append entries from maps, preferring last.
 * [📘](https://github.com/nodef/extra-map/wiki/concat)
 * @param xs maps
 * @returns x₀ ∪ x₁ ∪ ... | [x₀, x₁, ...] = xs
 */
declare function concat<K, V>(...xs: Entries<K, V>[]): Map<K, V>;
/**
 * Append entries from maps, preferring last.
 * [📘](https://github.com/nodef/extra-map/wiki/concat$)
 * @param x a map (updated)
 * @param ys other maps
 * @returns x = x ∪ y₀ ∪ y₁ ∪ ... | [y₀, y₁, ...] = ys
 */
declare function concat$<K, V>(x: Map<K, V>, ...ys: Entries<K, V>[]): Map<K, V>;
/**
 * Join entries together into a string.
 * [📘](https://github.com/nodef/extra-map/wiki/join)
 * @param x a map
 * @param sep separator [,]
 * @param asc associator [=]
 * @returns "$\{k₀\}=$\{v₀\},$\{k₁\}=$\{v₁\}..." | [kᵢ, vᵢ] ∈ x
 */
declare function join<K, V>(x: Entries<K, V>, sep?: string, asc?: string): string;
/**
 * Check if maps have no common keys.
 * [📘](https://github.com/nodef/extra-map/wiki/isDisjoint)
 * @param x a map
 * @param y another map
 * @returns x ∩ y = Φ?
 */
declare function isDisjoint<K, V>(x: Map<K, V>, y: Entries<K, V>): boolean;
/**
 * Obtain keys present in any map.
 * [📘](https://github.com/nodef/extra-map/wiki/unionKeys)
 * @param xs maps
 * @returns [k₀, k₁, ...] | [kᵢ, vᵢ] ∈ x₀ ∪ x₁, ...; [x₀, x₁, ...] = xs
 */
declare function unionKeys<K, V>(...xs: Entries<K, V>[]): Set<K>;
/**
 * Obtain entries present in any map.
 * [📘](https://github.com/nodef/extra-map/wiki/union)
 * @param x a map
 * @param y another map
 * @param fc combine function (a, b)
 * @returns x ∪ y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x or [kᵢ, vᵢ] ∈ y\}
 */
declare function 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$)
 * @param x a map (updated)
 * @param y another map
 * @param fc combine function (a, b)
 * @returns x = x ∪ y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x or [kᵢ, vᵢ] ∈ y\}
 */
declare function union$<K, V>(x: Map<K, V>, y: Entries<K, V>, fc?: CombineFunction<V> | null): Map<K, V>;
/**
 * Obtain keys present in all maps.
 * [📘](https://github.com/nodef/extra-map/wiki/intersectionKeys)
 * @param xs maps
 * @returns [k₀, k₁, ...] | [kᵢ, vᵢ] ∈ x₀ ∩ x₁, ...; [x₀, x₁, ...] = xs
 */
declare function intersectionKeys<K, V>(...xs: Map<K, V>[]): Set<K>;
/**
 * Obtain entries present in both maps.
 * [📘](https://github.com/nodef/extra-map/wiki/intersection)
 * @param x a map
 * @param y another map
 * @param fc combine function (a, b)
 * @returns x ∩ y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x and [kᵢ, vᵢ] ∈ y\}
 */
declare function 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$)
 * @param x a map (updated)
 * @param y another map
 * @param fc combine function (a, b)
 * @returns x = x ∩ y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x and [kᵢ, vᵢ] ∈ y\}
 */
declare function intersection$<K, V>(x: Map<K, V>, y: Map<K, V>, fc?: CombineFunction<V> | null): Map<K, V>;
/**
 * Obtain entries not present in another map.
 * [📘](https://github.com/nodef/extra-map/wiki/difference)
 * @param x a map
 * @param y another map
 * @returns x - y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x, [kᵢ, *] ∉ y\}
 */
declare function 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$)
 * @param x a map (updated)
 * @param y another map
 * @returns x = x - y = \{[kᵢ, vᵢ] | [kᵢ, vᵢ] ∈ x, [kᵢ, *] ∉ y\}
 */
declare function difference$<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)
 * @param x a map
 * @param y another map
 * @returns x-y ∪ y-x
 */
declare function 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$)
 * @param x a map (updated)
 * @param y another map
 * @returns x = x-y ∪ y-x
 */
declare function symmetricDifference$<K, V>(x: Map<K, V>, y: Entries<K, V>): Map<K, V>;
/**
 * List cartesian product of maps.
 * [📘](https://github.com/nodef/extra-map/wiki/cartesianProduct)
 * @param xs maps
 * @param fm map function (vs, i)
 * @returns x₀ × x₁ × ... = \{\{[k₀, v₀], [k₁, v₁], ...\} | [k₀, v₀] ∈ x₀, [k₁, v₁] ∈ x₁, ...]\}
 */
declare function 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>;

export { type CombineFunction, type CompareFunction, type EndFunction, type Entries, type Lists, type MapFunction, type ProcessFunction, type ReadFunction, type ReduceFunction, type TestFunction, cartesianProduct, chunk, compare, concat, concat$, count, countAs, difference, difference$, drop, drop$, entries, randomEntry as entry, every, filter, filter$, filterAt, filterAt$, find, findAll, flat, flatMap, forEach, from, from$, from as fromEntries, from$ as fromEntries$, fromKeys, fromLists, fromValues, get, getAll, getPath, has, hasEntry, has as hasKey, hasPath, hasSubset, hasValue, head, intersection, intersection$, intersectionKeys, is, isDisjoint, isEmpty, isEqual, join, randomKey as key, keys, size as length, map, map$, max, maxEntry, min, minEntry, partition, partitionAs, randomEntry, randomKey, randomSubset, range, rangeEntries, reduce, reject, reject$, rejectAt, rejectAt$, remove, remove$, removePath$, search, searchAll, searchValue, searchValueAll, set, set$, setPath$, size, some, randomSubset as subset, subsets, swap, swap$, symmetricDifference, symmetricDifference$, tail, take, take$, union, union$, unionKeys, values, zip };
