takeRightWhile es-toolkit
Returns a new array by taking elements from the end of the array while the condition function returns true.
Usage
takeRightWhile(arr, shouldContinueTaking)
Use takeRightWhile when you want to take elements from the end of an array that meet a condition. It stops when it encounters the first element for which the condition function returns false.
Parameters
The array to take elements from.
A condition function called with each element, its index, and the array. Elements are included in the result as long as this function returns true.
Returns
A new array containing the elements taken from the end while the condition function returns true.
Examples
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.