/** * Core array manipulation functions */ /** * Fills elements of array with value from start up to, but not including, end. * * @param array - The array to fill * @param value - The value to fill array with * @param start - The start position * @param end - The end position * @returns Returns array * * @example * const array = [1, 2, 3]; * * fill(array, 'a'); * // => ['a', 'a', 'a'] * * fill(Array(3), 2); * // => [2, 2, 2] * * fill([4, 6, 8, 10], '*', 1, 3); * // => [4, '*', '*', 10] */ export declare function fill(array: T[], value: U, start?: number, end?: number): (T | U)[]; /** * This method is like `find` except that it returns the index of the first * element predicate returns truthy for instead of the element itself. * * @param array - The array to inspect * @param predicate - The function invoked per iteration * @param fromIndex - The index to search from * @returns Returns the index of the found element, else -1 * * @example * const users = [ * { 'user': 'barney', 'active': false }, * { 'user': 'fred', 'active': false }, * { 'user': 'pebbles', 'active': true } * ]; * * findIndex(users, o => o.user == 'barney'); * // => 0 */ export declare function findIndex(array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean, fromIndex?: number): number; /** * This method is like `findIndex` except that it iterates over elements * of collection from right to left. * * @param array - The array to inspect * @param predicate - The function invoked per iteration * @param fromIndex - The index to search from * @returns Returns the index of the found element, else -1 */ export declare function findLastIndex(array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean, fromIndex?: number): number; /** * Gets the first element of array. * * @param array - The array to query * @returns Returns the first element of array * * @example * head([1, 2, 3]); * // => 1 * * head([]); * // => undefined */ export declare function head(array: readonly T[]): T | undefined; /** * Gets the element at index `n` of `array`. If `n` is negative, the nth * element from the end is returned. * * @param array - The array to query * @param n - The index of the element to return * @returns Returns the nth element of array * * @example * const array = ['a', 'b', 'c', 'd']; * * nth(array, 1); * // => 'b' * * nth(array, -2); * // => 'c' */ export declare function nth(array: readonly T[], n?: number): T | undefined; /** * Reverses array so that the first element becomes the last, the second * element becomes the second to last, and so on. * * @param array - The array to modify * @returns Returns array * * @example * const array = [1, 2, 3]; * * reverse(array); * // => [3, 2, 1] * * console.log(array); * // => [3, 2, 1] */ export declare function reverse(array: T[]): T[]; /** * Creates a slice of array from start up to, but not including, end. * * @param array - The array to slice * @param start - The start position * @param end - The end position * @returns Returns the slice of array * * @example * slice([1, 2, 3, 4], 2); * // => [3, 4] * * slice([1, 2, 3, 4], 1, 3); * // => [2, 3] * * slice([1, 2, 3, 4], -2); * // => [3, 4] */ export declare function slice(array: readonly T[], start?: number, end?: number): T[]; /** * Creates an array of elements, sorted in ascending order by the results * of running each element in a collection thru each iteratee. * * @param collection - The collection to iterate over * @param iteratees - The iteratees to sort by * @returns Returns the new sorted array * * @example * const users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, * { 'user': 'fred', 'age': 30 }, * { 'user': 'barney', 'age': 34 } * ]; * * sortBy(users, ['user', 'age']); * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] */ export declare function sortBy(collection: readonly T[], ...iteratees: Array<((value: T) => any) | string>): T[]; /** * Gets all but the first element of array. * * @param array - The array to query * @returns Returns the slice of array * * @example * tail([1, 2, 3]); * // => [2, 3] */ export declare function tail(array: readonly T[]): T[]; /** * Creates a slice of array with n elements taken from the beginning. * * @param array - The array to query * @param n - The number of elements to take * @returns Returns the slice of array * * @example * take([1, 2, 3]); * // => [1] * * take([1, 2, 3], 2); * // => [1, 2] * * take([1, 2, 3], 5); * // => [1, 2, 3] * * take([1, 2, 3], 0); * // => [] */ export declare function take(array: readonly T[], n?: number): T[]; /** * Creates a slice of array with n elements taken from the end. * * @param array - The array to query * @param n - The number of elements to take * @returns Returns the slice of array * * @example * takeRight([1, 2, 3]); * // => [3] * * takeRight([1, 2, 3], 2); * // => [2, 3] * * takeRight([1, 2, 3], 5); * // => [1, 2, 3] * * takeRight([1, 2, 3], 0); * // => [] */ export declare function takeRight(array: readonly T[], n?: number): T[]; /** * Creates a slice of array with elements taken from the beginning. Elements * are taken until predicate returns falsy. * * @param array - The array to query * @param predicate - The function invoked per iteration * @returns Returns the slice of array * * @example * const users = [ * { 'user': 'barney', 'active': false }, * { 'user': 'fred', 'active': false }, * { 'user': 'pebbles', 'active': true } * ]; * * takeWhile(users, o => !o.active); * // => objects for ['barney', 'fred'] */ export declare function takeWhile(array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): T[]; /** * Creates a slice of array with elements taken from the end. Elements are * taken until predicate returns falsy. * * @param array - The array to query * @param predicate - The function invoked per iteration * @returns Returns the slice of array * * @example * const users = [ * { 'user': 'barney', 'active': true }, * { 'user': 'fred', 'active': false }, * { 'user': 'pebbles', 'active': false } * ]; * * takeRightWhile(users, o => !o.active); * // => objects for ['fred', 'pebbles'] */ export declare function takeRightWhile(array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): T[]; /** * Creates an array of unique values that is the symmetric difference of * the given arrays. The order of result values is determined by the order * they occur in the arrays. * * @param arrays - The arrays to inspect * @returns Returns the new array of filtered values * * @example * xor([2, 1], [2, 3]); * // => [1, 3] */ export declare function xor(...arrays: readonly T[][]): T[]; /** * This method is like `xor` except that it accepts `iteratee` which is * invoked for each element of each `arrays` to generate the criterion by * which by which they're compared. * * @param arrays - The arrays to inspect * @param iteratee - The iteratee invoked per element * @returns Returns the new array of filtered values */ export declare function xorBy(...args: [...arrays: readonly T[][], iteratee: (value: T) => U]): T[]; /** * This method is like `xor` except that it accepts `comparator` which is * invoked to compare elements of `arrays`. * * @param arrays - The arrays to inspect * @param comparator - The comparator invoked per element * @returns Returns the new array of filtered values */ export declare function xorWith(...args: [ ...arrays: readonly T[][], comparator: (arrVal: T, othVal: T) => boolean ]): T[]; /** * Creates an array of grouped elements, the first of which contains the * first elements of the given arrays, the second of which contains the * second elements of the given arrays, and so on. * * @param arrays - The arrays to process * @returns Returns the new array of grouped elements * * @example * zip(['a', 'b'], [1, 2], [true, false]); * // => [['a', 1, true], ['b', 2, false]] */ export declare function zip(...arrays: readonly T[][]): T[][]; /** * This method is like `fromPairs` except that it accepts two arrays, * one of property identifiers and one of corresponding values. * * @param props - The property identifiers * @param values - The property values * @returns Returns the new object * * @example * zipObject(['a', 'b'], [1, 2]); * // => { 'a': 1, 'b': 2 } */ export declare function zipObject(props: readonly K[], values: readonly V[]): Record; /** * This method is like `zipObject` except that it supports property paths. * * @param paths - The property paths * @param values - The property values * @returns Returns the new object */ export declare function zipObjectDeep(paths: readonly (string | string[])[], values: readonly T[]): Record; /** * Gets the first element of array (alias for head). * * @param array - The array to query * @returns Returns the first element of array * * @example * first([1, 2, 3]); * // => 1 * * first([]); * // => undefined */ export declare function first(array: readonly T[]): T | undefined; /** * Gets the last element of array. * * @param array - The array to query * @returns Returns the last element of array * * @example * last([1, 2, 3]); * // => 3 */ export declare function last(array: readonly T[]): T | undefined; /** * Gets all but the first element of array. * * @param array - The array to query * @returns Returns the slice of array * * @example * rest([1, 2, 3]); * // => [2, 3] */ export declare function rest(array: readonly T[]): T[]; /** * Gets all but the last element of array. * * @param array - The array to query * @returns Returns the slice of array * * @example * initial([1, 2, 3]); * // => [1, 2] */ export declare function initial(array: readonly T[]): T[]; /** * Creates a slice of array with n elements taken from the beginning. * * @param array - The array to query * @param n - The number of elements to take * @returns Returns the slice of array * * @example * pull([1, 2, 3, 1, 2, 3], 2, 3); * // => [1, 1] */ export declare function pull(array: T[], ...values: T[]): T[]; /** * This method is like `pull` except that it accepts an array of values to remove. * * @param array - The array to modify * @param values - The values to remove * @returns Returns array * * @example * const array = ['a', 'b', 'c', 'a', 'b', 'c']; * * pullAll(array, ['a', 'c']); * console.log(array); * // => ['b', 'b'] */ export declare function pullAll(array: T[], values: readonly T[]): T[]; /** * Removes all given values from array using SameValueZero for equality comparisons. * * @param array - The array to modify * @param values - The values to remove * @returns Returns array * * @example * const array = [1, 2, 3, 1, 2, 3]; * * remove(array, n => n === 2); * console.log(array); * // => [1, 3, 1, 3] */ export declare function remove(array: T[], predicate: (value: T, index: number, array: T[]) => boolean): T[]; /** * Creates an array of unique values, in order, from all given arrays. * * @param arrays - The arrays to inspect * @returns Returns the new array of combined values * * @example * concat([1], 2, [3], [[4]]); * // => [1, 2, 3, [4]] */ export declare function concat(...args: (T | T[])[]): T[]; /** * Creates an array of array values not included in the other given arrays. * * @param array - The array to inspect * @param values - The values to exclude * @returns Returns the new array of filtered values * * @example * without([2, 1, 2, 3], 1, 2); * // => [3] */ export declare function without(array: readonly T[], ...values: T[]): T[]; /** * Creates an array excluding all given values. * * @param array - The array to inspect * @param start - The start position * @param end - The end position * @returns Returns the new array * * @example * indexOf([1, 2, 1, 2], 2); * // => 1 * * indexOf([1, 2, 1, 2], 2, 2); * // => 3 */ export declare function indexOf(array: readonly T[], value: T, fromIndex?: number): number; /** * This method is like `indexOf` except that it iterates over elements of array from right to left. * * @param array - The array to inspect * @param value - The value to search for * @param fromIndex - The index to search from * @returns Returns the index of the matched value, else -1 * * @example * lastIndexOf([1, 2, 1, 2], 2); * // => 3 * * lastIndexOf([1, 2, 1, 2], 2, 2); * // => 1 */ export declare function lastIndexOf(array: readonly T[], value: T, fromIndex?: number): number; /** * Creates an array with all falsey values removed. * * @param array - The array to compact * @returns Returns the new array of filtered values * * @example * join(['a', 'b', 'c'], '~'); * // => 'a~b~c' */ export declare function join(array: readonly T[], separator?: string): string;