import type { Predicate, Iteratee, PropertyPath, GroupedResult } from "../types"; /** * Iterates over elements of collection and invokes iteratee for each element. * The iteratee is invoked with three arguments: (value, index|key, collection). * Iteratee functions may exit iteration early by explicitly returning false. * * @param collection - The collection to iterate over * @param iteratee - The function invoked per iteration * @returns Returns collection * * @example * forEach([1, 2], value => console.log(value)); * // => Logs `1` then `2` * * forEach({ 'a': 1, 'b': 2 }, (value, key) => console.log(key)); * // => Logs 'a' then 'b' */ export declare function forEach(collection: readonly T[] | Record | null | undefined, iteratee?: (value: T, index: number | string, collection: readonly T[] | Record) => void | boolean): readonly T[] | Record | null | undefined; /** * This method is like `forEach` except that it iterates over elements of * collection from right to left. * * @param collection - The collection to iterate over * @param iteratee - The function invoked per iteration * @returns Returns collection * * @example * forEachRight([1, 2], value => console.log(value)); * // => Logs `2` then `1` */ export declare function forEachRight(collection: readonly T[] | Record | null | undefined, iteratee?: (value: T, index: number | string, collection: readonly T[] | Record) => void | boolean): readonly T[] | Record | null | undefined; /** * Checks if value is in collection. If collection is a string, it's * checked for a substring of value. * * @param collection - The collection to inspect * @param value - The value to search for * @param fromIndex - The index to search from * @returns Returns true if value is found, else false * * @example * includes([1, 2, 3], 1); * // => true * * includes([1, 2, 3], 1, 2); * // => false * * includes({ 'a': 1, 'b': 2 }, 1); * // => true * * includes('abcd', 'bc'); * // => true */ export declare function includes(collection: readonly T[] | Record | string | null | undefined, value: T, fromIndex?: number): boolean; /** * Invokes the method at path of each element in collection, returning * an array of the results of each invoked method. * * @param collection - The collection to iterate over * @param path - The path of the method to invoke * @param args - The arguments to invoke each method with * @returns Returns the array of results * * @example * invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); * // => [[1, 5, 7], [1, 2, 3]] */ export declare function invokeMap(collection: readonly T[], path: string | ((this: T, ...args: any[]) => R), ...args: any[]): R[]; /** * Creates an object composed of keys generated from the results of running * each element of collection thru iteratee. * * @param collection - The collection to iterate over * @param iteratee - The iteratee to transform keys * @returns Returns the composed aggregate object * * @example * groupBy(['one', 'two', 'three'], 'length'); * // => { '3': ['one', 'two'], '5': ['three'] } */ export declare function groupBy(collection: readonly T[], iterateeFunc?: ((value: T) => PropertyKey) | PropertyPath | Partial): GroupedResult; /** * Enhanced groupBy that groups by multiple keys. * This is an advanced utility beyond standard Lodash. * * @param collection - The collection to iterate over * @param iteratees - The iteratees to transform keys * @returns Returns the composed aggregate object * * @example * const users = [ * { name: 'John', age: 25, department: 'IT' }, * { name: 'Jane', age: 25, department: 'HR' }, * { name: 'Bob', age: 30, department: 'IT' } * ]; * * groupByMultiple(users, ['age', 'department']); * // => { * // '25_IT': [{ name: 'John', age: 25, department: 'IT' }], * // '25_HR': [{ name: 'Jane', age: 25, department: 'HR' }], * // '30_IT': [{ name: 'Bob', age: 30, department: 'IT' }] * // } */ export declare function groupByMultiple(collection: readonly T[], iteratees: ReadonlyArray<((value: T) => PropertyKey) | PropertyPath>): GroupedResult; /** * Creates an object composed of keys generated from the results of running * each element of collection thru iteratee. The corresponding value of * each key is the number of times the key was returned by iteratee. * * @param collection - The collection to iterate over * @param iteratee - The iteratee to transform keys * @returns Returns the composed aggregate object * * @example * countBy(['one', 'two', 'three'], 'length'); * // => { '3': 2, '5': 1 } */ export declare function countBy(collection: readonly T[], iterateeFunc?: ((value: T) => PropertyKey) | PropertyPath | Partial): Record; /** * Checks if predicate returns truthy for all elements of collection. * Iteration is stopped once predicate returns falsy. * * @param collection - The collection to iterate over * @param predicate - The function invoked per iteration * @returns Returns true if all elements pass the predicate check, else false * * @example * every([true, 1, null, 'yes'], Boolean); * // => false * * const users = [ * { 'user': 'barney', 'age': 36, 'active': false }, * { 'user': 'fred', 'age': 40, 'active': false } * ]; * * every(users, { 'active': false }); * // => true */ export declare function every(collection: readonly T[], predicate?: ((value: T, index?: number, collection?: readonly T[]) => boolean) | PropertyPath | Partial): boolean; /** * Checks if predicate returns truthy for any element of collection. * Iteration is stopped once predicate returns truthy. * * @param collection - The collection to iterate over * @param predicate - The function invoked per iteration * @returns Returns true if any element passes the predicate check, else false * * @example * some([null, 0, 'yes', false], Boolean); * // => true * * const users = [ * { 'user': 'barney', 'active': true }, * { 'user': 'fred', 'active': false } * ]; * * some(users, { 'active': false }); * // => true */ export declare function some(collection: readonly T[], predicate?: Predicate | PropertyPath | Partial): boolean; /** * Iterates over elements of collection, returning an array of all elements * predicate returns truthy for. * * @param collection - The collection to iterate over * @param predicate - The function invoked per iteration * @returns Returns the new filtered array * * @example * const users = [ * { 'user': 'barney', 'age': 36, 'active': true }, * { 'user': 'fred', 'age': 40, 'active': false } * ]; * * filter(users, o => !o.active); * // => objects for ['fred'] */ export declare function filter(collection: readonly T[], predicate?: Predicate | PropertyPath | Partial): T[]; /** * Iterates over elements of collection, returning the first element * predicate returns truthy for. * * @param collection - The collection to iterate over * @param predicate - The function invoked per iteration * @param fromIndex - The index to search from * @returns Returns the matched element, else undefined * * @example * const users = [ * { 'user': 'barney', 'age': 36, 'active': true }, * { 'user': 'fred', 'age': 40, 'active': false }, * { 'user': 'pebbles', 'age': 1, 'active': true } * ]; * * find(users, o => o.age < 40); * // => object for 'barney' */ export declare function find(collection: readonly T[], predicate?: Predicate | PropertyPath | Partial, fromIndex?: number): T | undefined; /** * This method is like `find` except that it iterates over elements of * collection from right to left. * * @param collection - The collection to iterate over * @param predicate - The function invoked per iteration * @param fromIndex - The index to search from * @returns Returns the matched element, else undefined */ export declare function findLast(collection: readonly T[], predicate?: Predicate | PropertyPath | Partial, fromIndex?: number): T | undefined; /** * Creates an array of values by running each element in collection thru iteratee. * * @param collection - The collection to iterate over * @param iteratee - The function invoked per iteration * @returns Returns the new mapped array * * @example * function square(n) { * return n * n; * } * * map([4, 8], square); * // => [16, 64] * * map({ 'a': 4, 'b': 8 }, square); * // => [16, 64] (iteration order is not guaranteed) * * const users = [ * { 'user': 'barney' }, * { 'user': 'fred' } * ]; * * map(users, 'user'); * // => ['barney', 'fred'] */ export declare function map(collection: readonly T[], iterateeFunc?: Iteratee | PropertyPath | Partial): U[]; /** * Reduces collection to a value which is the accumulated result of running * each element in collection thru iteratee, where each successive invocation * is supplied the return value of the previous. * * @param collection - The collection to iterate over * @param iteratee - The function invoked per iteration * @param accumulator - The initial value * @returns Returns the accumulated value * * @example * reduce([1, 2], (sum, n) => sum + n, 0); * // => 3 * * reduce({ 'a': 1, 'b': 2, 'c': 1 }, (result, value, key) => { * (result[value] || (result[value] = [])).push(key); * return result; * }, {}); * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) */ export declare function reduce(collection: readonly T[], iteratee: (accumulator: U, value: T, index: number, collection: readonly T[]) => U, accumulator?: U): U; /** * This method is like `reduce` except that it iterates over elements of * collection from right to left. * * @param collection - The collection to iterate over * @param iteratee - The function invoked per iteration * @param accumulator - The initial value * @returns Returns the accumulated value */ export declare function reduceRight(collection: readonly T[], iteratee: (accumulator: U, value: T, index: number, collection: readonly T[]) => U, accumulator?: U): U; /** * Creates an array of elements split into two groups, the first of which * contains elements predicate returns truthy for, the second of which * contains elements predicate returns falsy for. * * @param collection - The collection to iterate over * @param predicate - The function invoked per iteration * @returns Returns the array of grouped elements * * @example * const users = [ * { 'user': 'barney', 'age': 36, 'active': false }, * { 'user': 'fred', 'age': 40, 'active': true }, * { 'user': 'pebbles', 'age': 1, 'active': false } * ]; * * partition(users, o => o.active); * // => objects for [['fred'], ['barney', 'pebbles']] */ export declare function partition(collection: readonly T[], predicate?: Predicate | PropertyPath | Partial): [T[], T[]]; /** * Gets the size of collection by returning its length for array-like * values or the number of own enumerable string keyed properties for objects. * * @param collection - The collection to inspect * @returns Returns the collection size * * @example * size([1, 2, 3]); * // => 3 * * size({ 'a': 1, 'b': 2 }); * // => 2 * * size('pebbles'); * // => 7 */ export declare function size(collection: any): number; /** * Sorts a collection by multiple criteria. * This is an advanced utility beyond standard Lodash. * * @param collection - The collection to iterate over * @param iteratees - The iteratees to sort by * @returns Returns the new sorted array * * @example * const users = [ * { 'name': 'John', 'age': 30, 'score': 85 }, * { 'name': 'Jane', 'age': 25, 'score': 90 }, * { 'name': 'Bob', 'age': 30, 'score': 75 } * ]; * * sortByMultiple(users, ['age', 'score']); * // => Sorted by age first, then by score * * sortByMultiple(users, [ * { key: 'age', order: 'desc' }, * { key: 'score', order: 'asc' } * ]); * // => Sorted by age descending, then by score ascending */ export declare function sortByMultiple(collection: readonly T[], iteratees: Array<((value: T) => any) | PropertyPath | { key: ((value: T) => any) | PropertyPath; order?: "asc" | "desc"; }>): T[];