Back to Es Toolkit

drop (Functional Programming)

docs/fp/reference/drop.md

1.49.0805 B
Original Source

drop (Functional Programming)

Creates a function that drops values from the beginning of an array. Use it with pipe.

typescript
const result = pipe(array, drop(count));

::: info

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

:::

Usage

drop removes the first count values from the piped array. It is lazy-capable inside pipe.

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

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

Parameters

  • count (number): The number of values to drop from the beginning.

Returns

((array: readonly T[]) => T[]): A function that maps a readonly T[] to the remaining values.