UNPKG

extra-object

Version:

A collection of methods for working with Objects.

788 lines (781 loc) • 29.3 kB
/** * Entries is a list of key-value pairs, with unique keys (indices). * [šŸ“˜](https://github.com/nodef/extra-object/wiki/Entries) */ type Entries = Iterable<[string, any]>; /** * Lists is a pair of key list and value list, with unique keys (indices). * [šŸ“˜](https://github.com/nodef/extra-object/wiki/Lists) */ type Lists = [Iterable<string>, Iterable<any>]; /** * Handle reading of a single value. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/ReadFunction) * @returns value */ type ReadFunction<T> = () => T; /** * Handle combining of two values. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/CombineFunction) * @param a a value * @param b another value * @returns combined value */ type CombineFunction = (a: any, b: any) => any; /** * Handle comparison of two values. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/CompareFunction) * @param a a value * @param b another value * @returns a<b: -ve, a=b: 0, a>b: +ve */ type CompareFunction = (a: any, b: any) => number; /** * Handle processing of values in an object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/ProcessFunction) * @param v value in object * @param k key of value in object * @param x object containing the value */ type ProcessFunction = (v: any, k: string, x: object) => void; /** * Handle selection of entries in an object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/TestFunction) * @param v value in object * @param k key of value in object * @param x object containing the value * @returns selected? */ type TestFunction = (v: any, k: string, x: object) => boolean; /** * Handle transformation of a value to another. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/MapFunction) * @param v value in object * @param k key of value in object * @param x object containing the value * @returns transformed value */ type MapFunction = (v: any, k: string, x: object) => any; /** * Handle reduction of multiple values into a single value. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/ReduceFunction) * @param acc accumulator (temporary result) * @param v value in object * @param k key of value in object * @param x object containing the value * @returns reduced value */ type ReduceFunction = (acc: any, v: any, k: string, x: object) => any; /** * Handle ending of a combined object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/EndFunction) * @param dones iᵗʰ object done? * @returns combined object done? */ type EndFunction = (dones: boolean[]) => boolean; /** * Check if value is an object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/is) * @param v a value * @returns v is an object? */ declare function is(v: any): v is object; /** * List all keys. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/keys) * @param x an object * @returns kā‚€, k₁, ... | [kįµ¢, vįµ¢] ∈ x */ declare function keys(x: object): Iterable<string>; /** * List all values. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/values) * @param x an object * @returns vā‚€, v₁, ... | [kįµ¢, vįµ¢] ∈ x */ declare function values(x: object): Iterable<any>; /** * List all key-value pairs. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/entries) * @param x an object * @returns [kā‚€, vā‚€], [k₁, v₁], ... | [kįµ¢, vįµ¢] ∈ x */ declare function entries(x: object): Entries; /** * Convert entries to object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/fromEntries) * @param x entries * @returns x as object */ declare function fromEntries(x: Entries): object; /** * Convert lists to object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/fromLists) * @param x lists, i.e. [keys, values] * @returns x as object */ declare function fromLists(x: Lists): object; /** * Compare two objects. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/compare) * @param x an object * @param y another object * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns x=y: 0, otherwise: -ve/+ve */ declare function compare(x: object, y: object, fc?: CompareFunction | null, fm?: MapFunction | null): number; /** * Check if two objects are equal. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/isEqual) * @param x an object * @param y another object * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns fm(x[kįµ¢]) ā‰ˆ fm(y[kįµ¢]) āˆ€ kįµ¢ ∈ x, y */ declare function isEqual(x: object, y: object, fc?: CompareFunction | null, fm?: MapFunction | null): boolean; /** * Get the number of keys in an object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/size) * @param x an object * @returns |x| */ declare function size(x: object): number; /** * Check if an object is empty. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/isEmpty) * @param x an object * @returns |x| = 0? */ declare function isEmpty(x: object): boolean; /** * Get value at specified key. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/get) * @param x an object * @param k key * @returns x[k] */ declare function get(x: object, k: string): any; /** * Get values at keys. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/getAll) * @param x an object * @param ks keys * @returns [x[k], x[l], ...] | [k, l, ...] = ks */ declare function getAll(x: object, ks: string[]): any[]; /** * Get value at path in a nested object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/getPath) * @param x a nested object * @param p path * @returns x[kā‚€][k₁][...] | [kā‚€, k₁, ...] = p */ declare function getPath(x: object, p: string[]): any; /** * Check if nested object has a path. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/hasPath) * @param x a nested object * @param p path * @returns x[kā‚€][k₁][...] exists? | [kā‚€, k₁, ...] = p */ declare function hasPath(x: object, p: string[]): boolean; /** * Set value at specified key. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/set) * @param x an object * @param k key * @param v value * @returns x' | x' = x; x'[k] = v */ declare function set(x: object, k: string, v: any): object; /** * Set value at specified key. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/set$) * @param x an object (updated) * @param k key * @param v value * @returns x | x[k] = v */ declare function set$(x: object, k: string, v: any): object; /** * Set value at path in a nested object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/setPath$) * @param x a nested object (updated) * @param p path * @param v value * @returns x | x[kā‚€][k₁][...] = v; [kā‚€, k₁, ...] = p */ declare function setPath$(x: object, p: string[], v: any): any; /** * Exchange two values in an object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/swap) * @param x an object * @param k a key * @param l another key * @returns x' | x' = x; x'[k] = x[l]; x'[l] = x[k] */ declare function swap(x: object, k: string, l: string): object; /** * Exchange two values in an object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/swap$) * @param x an object (updated) * @param k a key * @param l another key * @returns x | x[i] ↔ x[j] */ declare function swap$(x: object, k: string, l: string): object; /** * Remove an entry from object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/remove) * @param x an object * @param k key * @returns x \\: [k] */ declare function remove(x: object, k: string): object; /** * Remove an entry from object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/remove$) * @param x an object (updated) * @param k key * @returns x = x \\: [k] */ declare function remove$(x: object, k: string): object; /** * Remove value at path in a nested object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/removePath$) * @param x a nested object (updated) * @param p path * @returns x = x \\: [kā‚€][k₁][...] | [kā‚€, k₁, ...] = p */ declare function removePath$(x: object, p: string[]): any; /** * Count values which satisfy a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/count) * @param x an object * @param ft test function (v, k, x) * @returns Ī£tįµ¢ | tįµ¢ = 1 if ft(vįµ¢) else 0; [kįµ¢, vįµ¢] ∈ x */ declare function count(x: object, ft: TestFunction): number; /** * Count occurrences of values. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/countAs) * @param x an object * @param fm map function (v, k, x) * @returns Map \{value ⇒ count\} */ declare function countAs(x: object, fm?: MapFunction | null): Map<any, number>; /** * Find smallest value. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/min) * @param x an object * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns v | v ≤ vįµ¢; [kįµ¢, vįµ¢] ∈ x */ declare function min(x: object, fc?: CompareFunction | null, fm?: MapFunction | null): any; /** * Find smallest entry. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/minEntry) * @param x an object * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [min_key, min_value] */ declare function minEntry(x: object, fc?: CompareFunction | null, fm?: MapFunction | null): [string, any]; /** * Find largest value. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/max) * @param x an object * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns v | v ≄ vįµ¢; [kįµ¢, vįµ¢] ∈ x */ declare function max(x: object, fc?: CompareFunction | null, fm?: MapFunction | null): any; /** * Find largest entry. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/maxEntry) * @param x an object * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [max_key, max_value] */ declare function maxEntry(x: object, fc?: CompareFunction | null, fm?: MapFunction | null): [string, any]; /** * Find smallest and largest values. * [šŸ“˜](https://github.com/nodef/extra-object/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(x: object, fc?: CompareFunction | null, fm?: MapFunction | null): [any, any]; /** * Find smallest and largest entries. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/rangeEntries) * @param x an object * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [min_entry, max_entry] */ declare function rangeEntries(x: object, fc?: CompareFunction | null, fm?: MapFunction | null): [[string, any], [string, any]]; /** * Gets first entry from object (default order). * [šŸ“˜](https://github.com/nodef/extra-object/wiki/head) * @param x an object * @param ed default entry * @returns [kā‚€, vā‚€] if x ≠ Φ else ed | [kā‚€, vā‚€] ∈ x */ declare function head(x: object, ed?: [string, any]): [string, any]; /** * Get object without its first entry (default order). * [šŸ“˜](https://github.com/nodef/extra-object/wiki/tail) * @param x an object * @returns x \\ \{[kā‚€, vā‚€]\} if x ≠ Φ else x | [kā‚€, vā‚€] ∈ x */ declare function tail(x: object): object; /** * Keep first n entries only (default order). * [šŸ“˜](https://github.com/nodef/extra-object/wiki/take) * @param x an object * @param n number of entries [1] * @returns \{[kā‚€, vā‚€], [k₁, v₁], ...\} | [kįµ¢, vįµ¢] ∈ x and |\{[kā‚€, vā‚€], [k₁, v₁], ...\}| ≤ n */ declare function take(x: object, n?: number): object; /** * Keep first n entries only (default order). * [šŸ“˜](https://github.com/nodef/extra-object/wiki/take$) * @param x an object (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$(x: object, n?: number): object; /** * Remove first n entries (default order). * [šŸ“˜](https://github.com/nodef/extra-object/wiki/drop) * @param x an object * @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(x: object, n?: number): object; /** * Remove first n entries (default order). * [šŸ“˜](https://github.com/nodef/extra-object/wiki/drop$) * @param x an object (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$(x: object, n?: number): object; /** * List all possible subsets. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/subsets) * @param x an object * @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(x: object, n?: number): IterableIterator<object>; /** * Pick an arbitrary key. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/randomKey) * @param x an object * @param fr random number generator ([0, 1)) * @returns kįµ¢ | [kįµ¢, vįµ¢] ∈ x */ declare function randomKey(x: object, fr?: ReadFunction<number> | null): string; /** * Pick an arbitrary entry. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/randomEntry) * @param x an object * @param fr random number generator ([0, 1)) * @returns [kįµ¢, vįµ¢] | [kįµ¢, vįµ¢] ∈ x */ declare function randomEntry(x: object, fr?: ReadFunction<number> | null): [string, any]; /** * Pick an arbitrary subset. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/randomSubset) * @param x an object * @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(x: object, n?: number, fr?: ReadFunction<number> | null): object; /** * Check if object has a key. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/has) * @param x an object * @param k search key * @returns [k, *] ∈ x? */ declare function has(x: object, k: string): boolean; /** * Check if object has a value. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/hasValue) * @param x an object * @param v search value * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [*, v] ∈ x? */ declare function hasValue(x: object, v: any, fc?: CompareFunction | null, fm?: MapFunction | null): boolean; /** * Check if object has an entry. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/hasEntry) * @param x an object * @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(x: object, e: [string, any], fc?: CompareFunction | null, fm?: MapFunction | null): boolean; /** * Check if object has a subset. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/hasSubset) * @param x an object * @param y search subset * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns y āŠ† x? */ declare function hasSubset(x: object, y: object, fc?: CompareFunction | null, fm?: MapFunction | null): boolean; /** * Find value of an entry passing a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/find) * @param x an object * @param ft test function (v, k, x) * @returns v | ft(v) = true; [k, v] ∈ x */ declare function find(x: object, ft: TestFunction): any; /** * Find values of entries passing a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/findAll) * @param x an object * @param ft test function (v, k, x) * @returns [vā‚’, v₁, ...] | ft(vįµ¢) = true; [kįµ¢, vįµ¢] ∈ x */ declare function findAll(x: object, ft: TestFunction): any[]; /** * Find key of an entry passing a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/search) * @param x an object * @param ft test function (v, k, x) * @returns k | ft(x[k]) passes */ declare function search(x: object, ft: TestFunction): string; /** * Find all keys of entries passing a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/searchAll) * @param x an object * @param ft test function (v, k, x) * @returns [kā‚€, k₁, ...] | ft(x[kįµ¢]) passes */ declare function searchAll(x: object, ft: TestFunction): string[]; /** * Find key with a given value. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/searchValue) * @param x an object * @param v search value * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns k | fm(x[k]) ā‰ˆ fm(v) */ declare function searchValue(x: object, v: any, fc?: CompareFunction | null, fm?: MapFunction | null): string; /** * Find keys with a given value. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/searchValueAll) * @param x an object * @param v search value * @param fc compare function (a, b) * @param fm map function (v, k, x) * @returns [kā‚€, k₁, ...] | fm(x[kįµ¢]) ā‰ˆ fm(v) */ declare function searchValueAll(x: object, v: any, fc?: CompareFunction | null, fm?: MapFunction | null): string[]; /** * Call a function for each entry. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/forEach) * @param x an object * @param fp called function (v, k, x) */ declare function forEach(x: object, fp: ProcessFunction): void; /** * Check if any value satisfies a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/some) * @param x an object * @param ft test function (v, k, x) * @returns true if ft(vįµ¢) = true for some [kįµ¢, vįµ¢] ∈ x */ declare function some(x: object, ft?: TestFunction | null): boolean; /** * Check if all values satisfy a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/every) * @param x an object * @param ft test function (v, k, x) * @returns true if ft(vįµ¢) = true for all [kįµ¢, vįµ¢] ∈ x */ declare function every(x: object, ft: TestFunction): boolean; /** * Transform values of an object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/map) * @param x an object * @param fm map function (v, k, x) * @returns \{[kā‚€, fm(vā‚€)], [k₁, fm(v₁)], ...\} | [kįµ¢, vįµ¢] ∈ x */ declare function map(x: object, fm: MapFunction): object; /** * Transform values of an object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/map$) * @param x an object (updated) * @param fm map function (v, k, x) * @returns x = \{[kā‚€, fm(vā‚€)], [k₁, fm(v₁)], ...\} | [kįµ¢, vįµ¢] ∈ x */ declare function map$(x: object, fm: MapFunction): object; /** * Reduce values to a single value. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/reduce) * @param x an object * @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(x: object, fr: ReduceFunction, acc?: any): any; /** * Keep entries which pass a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/filter) * @param x an object * @param ft test function (v, k, x) * @returns \{[kā‚€, vā‚€], [k₁, v₁], ...\} | ft(vįµ¢) = true; [kįµ¢, vįµ¢] ∈ x */ declare function filter(x: object, ft: TestFunction): object; /** * Keep entries which pass a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/filter$) * @param x an object (updated) * @param ft test function (v, k, x) * @returns x = \{[kā‚€, vā‚€], [k₁, v₁], ...\} | ft(vįµ¢) = true; [kįµ¢, vįµ¢] ∈ x */ declare function filter$(x: object, ft: TestFunction): object; /** * Get object with given keys. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/filterAt) * @param x an object * @param ks keys * @returns \{[kā‚€, vā‚€], [k₁, v₁], ...\} | kįµ¢ ∈ ks; [kįµ¢, vįµ¢] ∈ x */ declare function filterAt(x: object, ks: string[]): object; /** * Get object with given keys. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/filterAt$) * @param x an object (updated) * @param ks keys * @returns x = \{[kā‚€, vā‚€], [k₁, v₁], ...\} | kįµ¢ ∈ ks; [kįµ¢, vįµ¢] ∈ x */ declare function filterAt$(x: object, ks: string[]): object; /** * Discard entries which pass a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/reject) * @param x an object * @param ft test function (v, k, x) * @returns \{[kā‚€, vā‚€], [k₁, v₁], ...\} | ft(vįµ¢) = false; [kįµ¢, vįµ¢] ∈ x */ declare function reject(x: object, ft: TestFunction): object; /** * Discard entries which pass a test. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/reject$) * @param x an object (updated) * @param ft test function (v, k, x) * @returns x = \{[kā‚€, vā‚€], [k₁, v₁], ...\} | ft(vįµ¢) = false; [kįµ¢, vįµ¢] ∈ x */ declare function reject$(x: object, ft: TestFunction): object; /** * Get object without given keys. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/rejectAt) * @param x an object * @param ks keys * @returns \{[kā‚€, vā‚€], [k₁, v₁], ...\} | kįµ¢ āˆ‰ ks; [kįµ¢, vįµ¢] ∈ x */ declare function rejectAt(x: object, ks: string[]): object; /** * Get object without given keys. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/rejectAt$) * @param x an object (updated) * @param ks keys * @returns x = \{[kā‚€, vā‚€], [k₁, v₁], ...\} | kįµ¢ āˆ‰ ks; [kįµ¢, vįµ¢] ∈ x */ declare function rejectAt$(x: object, ks: string[]): object; /** * Flatten nested object to given depth. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/flat) * @param x a nested object * @param n maximum depth [-1 ⇒ all] * @param fm map function (v, k, x) * @param ft test function for flatten (v, k, x) * @returns flat map */ declare function flat(x: object, n?: number, fm?: MapFunction | null, ft?: TestFunction | null): object; /** * Flatten nested object, using map function. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/flatMap) * @param x a nested object * @param fm map function (v, k, x) * @param ft test function (v, k, x) * @returns flat map */ declare function flatMap(x: object, fm?: MapFunction | null, ft?: TestFunction | null): object; /** * Combine matching entries from objects. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/zip) * @param xs objects * @param fm map function (vs, k) * @param fe end function (dones) [array.some] * @param vd default value * @returns \{"kā‚€": fm([xā‚€[kā‚€], x₁[kā‚€], ...]), "k₁": fm([xā‚€[k₁], x₁[k₁], ...]), ...\} */ declare function zip(xs: object[], fm?: MapFunction | null, fe?: EndFunction | null, vd?: any): object; /** * Segregate entries by test result. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/partition) * @param x an object * @param ft test function (v, k, x) * @returns [satisfies, doesnt] */ declare function partition(x: object, ft: TestFunction): [object, object]; /** * Segregate entries by similarity. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/partitionAs) * @param x an object * @param fm map function (v, k, x) * @returns Map \{key ⇒ values\} */ declare function partitionAs(x: object, fm: MapFunction): Map<any, object>; /** * Break object into chunks of given size. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/chunk) * @param x an object * @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(x: object, n?: number, s?: number): object[]; /** * Combine entries from objects, preferring last. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/concat) * @param xs objects * @returns xā‚€ ∪ x₁ ∪ ... | [xā‚€, x₁, ...] = xs */ declare function concat(...xs: object[]): object; /** * Combines entries from objects, preferring last. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/concat$) * @param x an object (updated) * @param ys other objects * @returns x = x ∪ yā‚€ ∪ y₁ ∪ ... | [yā‚€, y₁, ...] = ys */ declare function concat$(x: object, ...ys: object[]): object; /** * Join entries together into a string. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/join) * @param x an object * @param sep separator [,] * @param asc associator [=] * @returns "kā‚€=vā‚€,k₁=v₁,..." | [kįµ¢, vįµ¢] ∈ x */ declare function join(x: object, sep?: string, asc?: string): string; /** * Check if objects have no common keys. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/isDisjoint) * @param x an object * @param y another object * @returns x ∩ y = Φ? */ declare function isDisjoint(x: object, y: object): boolean; /** * Obtain keys present in any object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/unionKeys) * @param xs objects * @returns [kā‚€, k₁, ...] | [kįµ¢, vįµ¢] ∈ xā‚€ ∪ x₁, ...; [xā‚€, x₁, ...] = xs */ declare function unionKeys(...xs: object[]): Set<string>; /** * Obtain entries present in any object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/union) * @param x an object * @param y another object * @param fc combine function (a, b) * @returns x ∪ y = \{[kįµ¢, vįµ¢] | [kįµ¢, vįµ¢] ∈ x or [kįµ¢, vįµ¢] ∈ y\} */ declare function union(x: object, y: object, fc?: CombineFunction | null): object; /** * Obtain entries present in any object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/union$) * @param x an object (updated) * @param y another object * @param fc combine function (a, b) * @returns x = x ∪ y = \{[kįµ¢, vįµ¢] | [kįµ¢, vįµ¢] ∈ x or [kįµ¢, vįµ¢] ∈ y\} */ declare function union$(x: object, y: object, fc?: CombineFunction | null): object; /** * Obtain keys present in all objects. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/intersectionKeys) * @param xs objects * @returns [kā‚€, k₁, ...] | [kįµ¢, vįµ¢] ∈ xā‚€ ∩ x₁, ...; [xā‚€, x₁, ...] = xs */ declare function intersectionKeys(...xs: object[]): Set<string>; /** * Obtain entries present in both objects. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/intersection) * @param x an object * @param y another object * @param fc combine function (a, b) * @returns x ∩ y = \{[kįµ¢, vįµ¢] | [kįµ¢, vįµ¢] ∈ x and [kįµ¢, vįµ¢] ∈ y\} */ declare function intersection(x: object, y: object, fc?: CombineFunction | null): object; /** * Obtain entries present in both objects. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/intersection$) * @param x an object (updated) * @param y another object * @param fc combine function (a, b) * @returns x = x ∩ y = \{[kįµ¢, vįµ¢] | [kįµ¢, vįµ¢] ∈ x and [kįµ¢, vįµ¢] ∈ y\} */ declare function intersection$(x: object, y: object, fc?: CombineFunction | null): object; /** * Obtain entries not present in another object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/difference) * @param x an object * @param y another object * @returns x - y = \{[kįµ¢, vįµ¢] | [kįµ¢, vįµ¢] ∈ x, [kįµ¢, *] āˆ‰ y\} */ declare function difference(x: object, y: object): object; /** * Obtain entries not present in another object. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/difference$) * @param x an object (updated) * @param y another object * @returns x = x - y = \{[kįµ¢, vįµ¢] | [kįµ¢, vįµ¢] ∈ x, [kįµ¢, *] āˆ‰ y\} */ declare function difference$(x: object, y: object): object; /** * Obtain entries not present in both objects. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/symmetricDifference) * @param x an object * @param y another object * @returns x-y ∪ y-x */ declare function symmetricDifference(x: object, y: object): object; /** * Obtain entries not present in both objects. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/symmetricDifference$) * @param x an object (updated) * @param y another object * @returns x = x-y ∪ y-x */ declare function symmetricDifference$(x: object, y: object): object; /** * List cartesian product of objects. * [šŸ“˜](https://github.com/nodef/extra-object/wiki/cartesianProduct) * @param xs objects * @param fm map function (vs) * @returns xā‚€ Ɨ x₁ Ɨ ... = \{\{[kā‚€, vā‚€], [k₁, v₁], ...\} | [kā‚€, vā‚€] ∈ xā‚€, [k₁, v₁] ∈ x₁, ...]\} */ declare function cartesianProduct(xs: object[], fm?: MapFunction | null): IterableIterator<any>; export { CombineFunction, CompareFunction, EndFunction, Entries, Lists, MapFunction, ProcessFunction, ReadFunction, ReduceFunction, 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, fromEntries, fromLists, 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 };