For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/fp/dropRightWhile.md.

dropRightWhile (Functional Programming) es-toolkit

Creates a function that drops trailing values while a predicate passes. Use it with pipe.

const result = pipe(array, dropRightWhile(predicate));
Info

Prefer the original es-toolkit dropRightWhile in ordinary code. Use this fp variant when composing transformations with pipe.

Usage

dropRightWhile walks the piped array from the end and removes values while predicate returns true. It stops at the first value that does not pass.

import { dropRightWhile, pipe } from 'es-toolkit/fp';

pipe(
  [1, 2, 3, 4],
  dropRightWhile(value => value > 2)
); // => [1, 2]

Parameters

predicate(item: T) => booleanrequired

The function that decides whether a trailing value should be dropped.

Returns

A function that maps a readonly T[] to the values left after dropping from the end.

(array: readonly T[]) => T[]
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.