| 1 | /**
|
|---|
| 2 | * Iterates over an object and invokes the `iteratee` function for each property.
|
|---|
| 3 | *
|
|---|
| 4 | * Iterates over string keyed properties including inherited properties.
|
|---|
| 5 | *
|
|---|
| 6 | * The iteration is terminated early if the `iteratee` function returns `false`.
|
|---|
| 7 | *
|
|---|
| 8 | * @template T - The type of the object
|
|---|
| 9 | * @param {T} object - The object to iterate over
|
|---|
| 10 | * @param {(value: T[keyof T], key: string, obj: T) => any} iteratee - The function invoked per iteration
|
|---|
| 11 | * @returns {T} Returns the object
|
|---|
| 12 | *
|
|---|
| 13 | * @example
|
|---|
| 14 | * // Iterate over all properties including inherited ones
|
|---|
| 15 | * const obj = { a: 1, b: 2 };
|
|---|
| 16 | * forIn(obj, (value, key) => {
|
|---|
| 17 | * console.log(key, value);
|
|---|
| 18 | * });
|
|---|
| 19 | * // Output: 'a' 1, 'b' 2
|
|---|
| 20 | *
|
|---|
| 21 | * // Early termination
|
|---|
| 22 | * forIn(obj, (value, key) => {
|
|---|
| 23 | * console.log(key, value);
|
|---|
| 24 | * return key !== 'a'; // stop after 'a'
|
|---|
| 25 | * });
|
|---|
| 26 | * // Output: 'a' 1
|
|---|
| 27 | */
|
|---|
| 28 | declare function forIn<T>(object: T, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T;
|
|---|
| 29 | /**
|
|---|
| 30 | * Iterates over an object and invokes the `iteratee` function for each property.
|
|---|
| 31 | *
|
|---|
| 32 | * Iterates over string keyed properties including inherited properties.
|
|---|
| 33 | *
|
|---|
| 34 | * The iteration is terminated early if the `iteratee` function returns `false`.
|
|---|
| 35 | *
|
|---|
| 36 | * @template T - The type of the object
|
|---|
| 37 | * @param {T | null | undefined} object - The object to iterate over
|
|---|
| 38 | * @param {(value: T[keyof T], key: string, obj: T) => any} iteratee - The function invoked per iteration
|
|---|
| 39 | * @returns {T | null | undefined} Returns the object
|
|---|
| 40 | *
|
|---|
| 41 | * @example
|
|---|
| 42 | * // Iterate over all properties including inherited ones
|
|---|
| 43 | * const obj = { a: 1, b: 2 };
|
|---|
| 44 | * forIn(obj, (value, key) => {
|
|---|
| 45 | * console.log(key, value);
|
|---|
| 46 | * });
|
|---|
| 47 | * // Output: 'a' 1, 'b' 2
|
|---|
| 48 | *
|
|---|
| 49 | * // Early termination
|
|---|
| 50 | * forIn(obj, (value, key) => {
|
|---|
| 51 | * console.log(key, value);
|
|---|
| 52 | * return key !== 'a'; // stop after 'a'
|
|---|
| 53 | * });
|
|---|
| 54 | * // Output: 'a' 1
|
|---|
| 55 | */
|
|---|
| 56 | declare function forIn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
|
|---|
| 57 |
|
|---|
| 58 | export { forIn };
|
|---|