UNPKG

arquero

Version:

Query processing and transformation of array-backed data tables.

95 lines (94 loc) 4.06 kB
/** * Returns a new compacted array with invalid values * (`null`, `undefined`, `NaN`) removed. * @template T * @param {T[]} array The input array. * @return {T[]} A compacted array. */ export function compact<T>(array: T[]): T[]; /** * Merges two or more arrays in sequence, returning a new array. * @template T * @param {...(T|T[])} values The arrays to merge. * @return {T[]} The merged array. */ export function concat<T>(...values: (T | T[])[]): T[]; /** * Determines whether an *array* includes a certain *value* among its * entries, returning `true` or `false` as appropriate. * @template T * @param {T[]} sequence The input array value. * @param {T} value The value to search for. * @param {number} [index=0] The integer index to start searching * from (default `0`). * @return {boolean} True if the value is included, false otherwise. */ export function includes<T>(sequence: T[], value: T, index?: number): boolean; /** * Returns the first index at which a given *value* can be found in the * *sequence* (array or string), or -1 if it is not present. * @template T * @param {T[]|string} sequence The input array or string value. * @param {T} value The value to search for. * @return {number} The index of the value, or -1 if not present. */ export function indexof<T>(sequence: T[] | string, value: T): number; /** * Creates and returns a new string by concatenating all of the elements * in an *array* (or an array-like object), separated by commas or a * specified *delimiter* string. If the *array* has only one item, then * that item will be returned without using the delimiter. * @template T * @param {T[]} array The input array value. * @param {string} delim The delimiter string (default `','`). * @return {string} The joined string. */ export function join<T>(array: T[], delim: string): string; /** * Returns the last index at which a given *value* can be found in the * *sequence* (array or string), or -1 if it is not present. * @template T * @param {T[]|string} sequence The input array or string value. * @param {T} value The value to search for. * @return {number} The last index of the value, or -1 if not present. */ export function lastindexof<T>(sequence: T[] | string, value: T): number; /** * Returns the length of the input *sequence* (array or string). * @param {Array|string} sequence The input array or string value. * @return {number} The length of the sequence. */ export function length(sequence: any[] | string): number; /** * Returns a new array in which the given *property* has been extracted * for each element in the input *array*. * @param {Array} array The input array value. * @param {string} property The property name string to extract. Nested * properties are not supported: the input `"a.b"` will indicates a * property with that exact name, *not* a nested property `"b"` of * the object `"a"`. * @return {Array} An array of plucked properties. */ export function pluck(array: any[], property: string): any[]; /** * Returns a new array or string with the element order reversed: the first * *sequence* element becomes the last, and the last *sequence* element * becomes the first. The input *sequence* is unchanged. * @template T * @param {T[]|string} sequence The input array or string value. * @return {T[]|string} The reversed sequence. */ export function reverse<T>(sequence: T[] | string): T[] | string; /** * Returns a copy of a portion of the input *sequence* (array or string) * selected from *start* to *end* (*end* not included) where *start* and * *end* represent the index of items in the sequence. * @template T * @param {T[]|string} sequence The input array or string value. * @param {number} [start=0] The starting integer index to copy from * (inclusive, default `0`). * @param {number} [end] The ending integer index to copy from (exclusive, * default `sequence.length`). * @return {T[]|string} The sliced sequence. */ export function slice<T>(sequence: T[] | string, start?: number, end?: number): T[] | string;