extra-map
Version:
A group of functions for working with Maps.
815 lines (805 loc) ⢠30.8 kB
TypeScript
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 };