import { ArrayIterator } from '../_internal/ArrayIterator.js'; import { ListIterator } from '../_internal/ListIterator.js'; import { ObjectIterator } from '../_internal/ObjectIterator.js'; import { StringIterator } from '../_internal/StringIterator.js'; /** * Iterates over elements of array and invokes iteratee for each element. * * @template T * @param {T[]} collection - The array to iterate over. * @param {ArrayIterator} [iteratee] - The function invoked per iteration. * @returns {T[]} Returns array. * * @example * forEach([1, 2], value => console.log(value)); * // => Logs `1` then `2`. */ declare function forEach(collection: T[], iteratee?: ArrayIterator): T[]; /** * Iterates over characters of string and invokes iteratee for each character. * * @param {string} collection - The string to iterate over. * @param {StringIterator} [iteratee] - The function invoked per iteration. * @returns {string} Returns string. * * @example * forEach('abc', char => console.log(char)); * // => Logs 'a', 'b', then 'c'. */ declare function forEach(collection: string, iteratee?: StringIterator): string; /** * Iterates over elements of collection and invokes iteratee for each element. * * @template T * @param {ArrayLike} collection - The collection to iterate over. * @param {ListIterator} [iteratee] - The function invoked per iteration. * @returns {ArrayLike} Returns collection. * * @example * forEach({ 0: 'a', 1: 'b', length: 2 }, value => console.log(value)); * // => Logs 'a' then 'b'. */ declare function forEach(collection: ArrayLike, iteratee?: ListIterator): ArrayLike; /** * Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property. * * @template T * @param {T} collection - The object to iterate over. * @param {ObjectIterator} [iteratee] - The function invoked per iteration. * @returns {T} Returns object. * * @example * forEach({ a: 1, b: 2 }, (value, key) => console.log(key)); * // => Logs 'a' then 'b'. */ declare function forEach(collection: T, iteratee?: ObjectIterator): T; /** * Iterates over elements of array and invokes iteratee for each element. * * @template T, U * @param {U & (T[] | null | undefined)} collection - The array to iterate over. * @param {ArrayIterator} [iteratee] - The function invoked per iteration. * @returns {U} Returns the array. * * @example * forEach([1, 2], value => console.log(value)); * // => Logs `1` then `2`. */ declare function forEach(collection: U & (T[] | null | undefined), iteratee?: ArrayIterator): U; /** * Iterates over characters of string and invokes iteratee for each character. * * @template T * @param {T} collection - The string to iterate over. * @param {StringIterator} [iteratee] - The function invoked per iteration. * @returns {T} Returns the string. * * @example * forEach('abc', char => console.log(char)); * // => Logs 'a', 'b', then 'c'. */ declare function forEach(collection: T, iteratee?: StringIterator): T; /** * Iterates over elements of collection and invokes iteratee for each element. * * @template T, L * @param {L & (ArrayLike | null | undefined)} collection - The collection to iterate over. * @param {ListIterator} [iteratee] - The function invoked per iteration. * @returns {L} Returns the collection. * * @example * forEach({ 0: 'a', 1: 'b', length: 2 }, value => console.log(value)); * // => Logs 'a' then 'b'. */ declare function forEach | null | undefined>(collection: L & (ArrayLike | null | undefined), iteratee?: ListIterator): L; /** * Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property. * * @template T * @param {T | null | undefined} collection - The object to iterate over. * @param {ObjectIterator} [iteratee] - The function invoked per iteration. * @returns {T | null | undefined} Returns the object. * * @example * forEach({ a: 1, b: 2 }, (value, key) => console.log(key)); * // => Logs 'a' then 'b'. */ declare function forEach(collection: T | null | undefined, iteratee?: ObjectIterator): T | null | undefined; export { forEach };