source: node_modules/es-toolkit/dist/array/takeRightWhile.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 945 bytes
Line 
1/**
2 * Takes elements from the end of the array while the predicate function returns `true`.
3 *
4 * @template T - Type of elements in the input array.
5 *
6 * @param {T[]} arr - The array to take elements from.
7 * @param {(item: T, index: number, array: readonly T[]) => boolean} shouldContinueTaking - The function invoked per element with the item, its index, and the array.
8 * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.
9 *
10 * @example
11 * // Returns [3, 2, 1]
12 * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);
13 *
14 * @example
15 * // Returns []
16 * takeRightWhile([1, 2, 3], n => n > 3);
17 *
18 * @example
19 * // Using index parameter
20 * takeRightWhile([10, 20, 30, 40], (x, index) => index > 1);
21 * // Returns: [30, 40]
22 */
23declare function takeRightWhile<T>(arr: readonly T[], shouldContinueTaking: (item: T, index: number, array: readonly T[]) => boolean): T[];
24
25export { takeRightWhile };
Note: See TracBrowser for help on using the repository browser.