| 1 | import { ArrayIterator } from '../_internal/ArrayIterator.js';
|
|---|
| 2 | import { ListIterator } from '../_internal/ListIterator.js';
|
|---|
| 3 | import { ObjectIterator } from '../_internal/ObjectIterator.js';
|
|---|
| 4 | import { StringIterator } from '../_internal/StringIterator.js';
|
|---|
| 5 |
|
|---|
| 6 | /**
|
|---|
| 7 | * Iterates over elements of array from right to left and invokes iteratee for each element.
|
|---|
| 8 | *
|
|---|
| 9 | * @template T
|
|---|
| 10 | * @param {T[]} collection - The array to iterate over.
|
|---|
| 11 | * @param {ArrayIterator<T, any>} [iteratee] - The function invoked per iteration.
|
|---|
| 12 | * @returns {T[]} Returns array.
|
|---|
| 13 | *
|
|---|
| 14 | * @example
|
|---|
| 15 | * forEachRight([1, 2], value => console.log(value));
|
|---|
| 16 | * // => Logs `2` then `1`.
|
|---|
| 17 | */
|
|---|
| 18 | declare function forEachRight<T>(collection: T[], iteratee?: ArrayIterator<T, any>): T[];
|
|---|
| 19 | /**
|
|---|
| 20 | * Iterates over characters of string from right to left and invokes iteratee for each character.
|
|---|
| 21 | *
|
|---|
| 22 | * @param {string} collection - The string to iterate over.
|
|---|
| 23 | * @param {StringIterator<any>} [iteratee] - The function invoked per iteration.
|
|---|
| 24 | * @returns {string} Returns string.
|
|---|
| 25 | *
|
|---|
| 26 | * @example
|
|---|
| 27 | * forEachRight('abc', char => console.log(char));
|
|---|
| 28 | * // => Logs 'c', 'b', then 'a'.
|
|---|
| 29 | */
|
|---|
| 30 | declare function forEachRight(collection: string, iteratee?: StringIterator<any>): string;
|
|---|
| 31 | /**
|
|---|
| 32 | * Iterates over elements of collection from right to left and invokes iteratee for each element.
|
|---|
| 33 | *
|
|---|
| 34 | * @template T
|
|---|
| 35 | * @param {ArrayLike<T>} collection - The collection to iterate over.
|
|---|
| 36 | * @param {ListIterator<T, any>} [iteratee] - The function invoked per iteration.
|
|---|
| 37 | * @returns {ArrayLike<T>} Returns collection.
|
|---|
| 38 | *
|
|---|
| 39 | * @example
|
|---|
| 40 | * forEachRight({ 0: 'a', 1: 'b', length: 2 }, value => console.log(value));
|
|---|
| 41 | * // => Logs 'b' then 'a'.
|
|---|
| 42 | */
|
|---|
| 43 | declare function forEachRight<T>(collection: ArrayLike<T>, iteratee?: ListIterator<T, any>): ArrayLike<T>;
|
|---|
| 44 | /**
|
|---|
| 45 | * Iterates over own enumerable string keyed properties of an object from right to left and invokes iteratee for each property.
|
|---|
| 46 | *
|
|---|
| 47 | * @template T
|
|---|
| 48 | * @param {T} collection - The object to iterate over.
|
|---|
| 49 | * @param {ObjectIterator<T, any>} [iteratee] - The function invoked per iteration.
|
|---|
| 50 | * @returns {T} Returns object.
|
|---|
| 51 | *
|
|---|
| 52 | * @example
|
|---|
| 53 | * forEachRight({ a: 1, b: 2 }, (value, key) => console.log(key));
|
|---|
| 54 | * // => Logs 'b' then 'a'.
|
|---|
| 55 | */
|
|---|
| 56 | declare function forEachRight<T extends object>(collection: T, iteratee?: ObjectIterator<T, any>): T;
|
|---|
| 57 | /**
|
|---|
| 58 | * Iterates over elements of array from right to left and invokes iteratee for each element.
|
|---|
| 59 | *
|
|---|
| 60 | * @template T, U
|
|---|
| 61 | * @param {U & (T[] | null | undefined)} collection - The array to iterate over.
|
|---|
| 62 | * @param {ArrayIterator<T, any>} [iteratee] - The function invoked per iteration.
|
|---|
| 63 | * @returns {U} Returns the array.
|
|---|
| 64 | *
|
|---|
| 65 | * @example
|
|---|
| 66 | * forEachRight([1, 2], value => console.log(value));
|
|---|
| 67 | * // => Logs `2` then `1`.
|
|---|
| 68 | */
|
|---|
| 69 | declare function forEachRight<T, U extends T[] | null | undefined>(collection: U & (T[] | null | undefined), iteratee?: ArrayIterator<T, any>): U;
|
|---|
| 70 | /**
|
|---|
| 71 | * Iterates over characters of string from right to left and invokes iteratee for each character.
|
|---|
| 72 | *
|
|---|
| 73 | * @template T
|
|---|
| 74 | * @param {T} collection - The string to iterate over.
|
|---|
| 75 | * @param {StringIterator<any>} [iteratee] - The function invoked per iteration.
|
|---|
| 76 | * @returns {T} Returns the string.
|
|---|
| 77 | *
|
|---|
| 78 | * @example
|
|---|
| 79 | * forEachRight('abc', char => console.log(char));
|
|---|
| 80 | * // => Logs 'c', 'b', then 'a'.
|
|---|
| 81 | */
|
|---|
| 82 | declare function forEachRight<T extends string | null | undefined>(collection: T, iteratee?: StringIterator<any>): T;
|
|---|
| 83 | /**
|
|---|
| 84 | * Iterates over elements of collection from right to left and invokes iteratee for each element.
|
|---|
| 85 | *
|
|---|
| 86 | * @template T, L
|
|---|
| 87 | * @param {L & (ArrayLike<T> | null | undefined)} collection - The collection to iterate over.
|
|---|
| 88 | * @param {ListIterator<T, any>} [iteratee] - The function invoked per iteration.
|
|---|
| 89 | * @returns {L} Returns the collection.
|
|---|
| 90 | *
|
|---|
| 91 | * @example
|
|---|
| 92 | * forEachRight({ 0: 'a', 1: 'b', length: 2 }, value => console.log(value));
|
|---|
| 93 | * // => Logs 'b' then 'a'.
|
|---|
| 94 | */
|
|---|
| 95 | declare function forEachRight<T, L extends ArrayLike<T> | null | undefined>(collection: L & (ArrayLike<T> | null | undefined), iteratee?: ListIterator<T, any>): L;
|
|---|
| 96 | /**
|
|---|
| 97 | * Iterates over own enumerable string keyed properties of an object from right to left and invokes iteratee for each property.
|
|---|
| 98 | *
|
|---|
| 99 | * @template T
|
|---|
| 100 | * @param {T | null | undefined} collection - The object to iterate over.
|
|---|
| 101 | * @param {ObjectIterator<T, any>} [iteratee] - The function invoked per iteration.
|
|---|
| 102 | * @returns {T | null | undefined} Returns the object.
|
|---|
| 103 | *
|
|---|
| 104 | * @example
|
|---|
| 105 | * forEachRight({ a: 1, b: 2 }, (value, key) => console.log(key));
|
|---|
| 106 | * // => Logs 'b' then 'a'.
|
|---|
| 107 | */
|
|---|
| 108 | declare function forEachRight<T extends object>(collection: T | null | undefined, iteratee?: ObjectIterator<T, any>): T | null | undefined;
|
|---|
| 109 |
|
|---|
| 110 | export { forEachRight };
|
|---|