takeRightWhile (Functional Programming) ​
Creates a function that takes trailing values while a predicate passes. Use it with pipe.
typescript
const result = pipe(array, takeRightWhile(predicate));INFO
Prefer the original es-toolkit takeRightWhile in ordinary code. Use this fp variant when composing transformations with pipe.
Usage ​
takeRightWhile walks the piped array from the end and keeps values while predicate returns true. It stops at the first value that does not pass.
typescript
import { pipe, takeRightWhile } from 'es-toolkit/fp';
pipe(
[1, 2, 3, 4],
takeRightWhile(value => value > 2)
); // => [3, 4]Parameters ​
predicate((item: T) => boolean): The function that decides whether a trailing value should be kept.
Returns ​
((array: readonly T[]) => T[]): A function that maps a readonly T[] to the trailing values that pass.

