arquero
Version:
Query processing and transformation of array-backed data tables.
57 lines (56 loc) • 2.75 kB
TypeScript
/**
* Returns a boolean indicating whether the *object* has the specified *key*
* as its own property (as opposed to inheriting it). If the *object* is a
* *Map* or *Set* instance, the *has* method will be invoked directly on the
* object, otherwise *Object.hasOwnProperty* is used.
* @template {string | number} K
* @template V
* @param {Map<K, V>|Set<K>|Record<K, V>} object The object, Map, or Set to
* test for property membership.
* @param {K} key The property key to test for.
* @return {boolean} True if the object has the given key, false otherwise.
*/
export function has<K extends string | number, V>(object: Map<K, V> | Set<K> | Record<K, V>, key: K): boolean;
/**
* Returns an array of a given *object*'s own enumerable property names. If
* the *object* is a *Map* instance, the *keys* method will be invoked
* directly on the object, otherwise *Object.keys* is used.
* @template {string | number} K
* @template V
* @param {Map<K, V>|Record<K, V>} object The input object or Map value.
* @return {K[]} An array of property key name strings.
*/
export function keys<K extends string | number, V>(object: Map<K, V> | Record<K, V>): K[];
/**
* Returns an array of a given *object*'s own enumerable property values. If
* the *object* is a *Map* or *Set* instance, the *values* method will be
* invoked directly on the object, otherwise *Object.values* is used.
* @template {string | number} K
* @template V
* @param {Map<K, V> | Set<V> | Record<K, V>} object The input object, Map,
* or Set value.
* @return {V[]} An array of property values.
*/
export function values<K extends string | number, V>(object: Map<K, V> | Set<V> | Record<K, V>): V[];
/**
* Returns an array of a given *object*'s own enumerable keyed property
* `[key, value]` pairs. If the *object* is a *Map* or *Set* instance, the
* *entries* method will be invoked directly on the object, otherwise
* *Object.entries* is used.
* @template {string | number} K
* @template V
* @param {Map<K, V> | Set<V> | Record<K, V>} object The input object, Map,
* or Set value.
* @return {[K, V][]} An array of property values.
*/
export function entries<K extends string | number, V>(object: Map<K, V> | Set<V> | Record<K, V>): [K, V][];
/**
* Returns a new object given iterable *entries* of `[key, value]` pairs.
* This method is Arquero's version of the *Object.fromEntries* method.
* @template {string | number} K
* @template V
* @param {Iterable<[K, V]>} entries An iterable collection of `[key, value]`
* pairs, such as an array of two-element arrays or a *Map*.
* @return {Record<K, V>} An object of consolidated key-value pairs.
*/
export function object<K extends string | number, V>(entries: Iterable<[K, V]>): Record<K, V>;