| 1 | /**
|
|---|
| 2 | * Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
|
|---|
| 3 | *
|
|---|
| 4 | * @template T - The type of elements in the array.
|
|---|
| 5 | * @param {T[]} arr - The array to iterate over.
|
|---|
| 6 | * @param {(value: T, index: number, arr: T[]) => void} callback - The function invoked per iteration.
|
|---|
| 7 | * The callback function receives three arguments:
|
|---|
| 8 | * - 'value': The current element being processed in the array.
|
|---|
| 9 | * - 'index': The index of the current element being processed in the array.
|
|---|
| 10 | * - 'arr': The array 'forEachRight' was called upon.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * const array = [1, 2, 3];
|
|---|
| 14 | * const result: number[] = [];
|
|---|
| 15 | *
|
|---|
| 16 | * // Use the forEachRight function to iterate through the array and add each element to the result array.
|
|---|
| 17 | * forEachRight(array, (value) => {
|
|---|
| 18 | * result.push(value);
|
|---|
| 19 | * })
|
|---|
| 20 | *
|
|---|
| 21 | * console.log(result) // Output: [3, 2, 1]
|
|---|
| 22 | */
|
|---|
| 23 | declare function forEachRight<T>(arr: T[], callback: (value: T, index: number, arr: T[]) => void): void;
|
|---|
| 24 | /**
|
|---|
| 25 | * Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.
|
|---|
| 26 | *
|
|---|
| 27 | * @template T - The type of elements in the array.
|
|---|
| 28 | * @param {T[]} arr - The array to iterate over.
|
|---|
| 29 | * @param {(value: T, index: number, arr: T[]) => void} callback - The function invoked per iteration.
|
|---|
| 30 | * The callback function receives three arguments:
|
|---|
| 31 | * - 'value': The current element being processed in the array.
|
|---|
| 32 | * - 'index': The index of the current element being processed in the array.
|
|---|
| 33 | * - 'arr': The array 'forEachRight' was called upon.
|
|---|
| 34 | *
|
|---|
| 35 | * @example
|
|---|
| 36 | * const array = [1, 2, 3];
|
|---|
| 37 | * const result: number[] = [];
|
|---|
| 38 | *
|
|---|
| 39 | * // Use the forEachRight function to iterate through the array and add each element to the result array.
|
|---|
| 40 | * forEachRight(array, (value) => {
|
|---|
| 41 | * result.push(value);
|
|---|
| 42 | * })
|
|---|
| 43 | *
|
|---|
| 44 | * console.log(result) // Output: [3, 2, 1]
|
|---|
| 45 | */
|
|---|
| 46 | declare function forEachRight<T>(arr: readonly T[], callback: (value: T, index: number, arr: readonly T[]) => void): void;
|
|---|
| 47 |
|
|---|
| 48 | export { forEachRight };
|
|---|