take (Functional Programming) es-toolkit
Creates a function that returns the first count elements of an array. Use it with pipe.
Usage
take returns the first count elements. If count is greater than the array length, the whole array is returned. For a non-negative integer count it is lazy-capable: inside a pipe it ends the walk as soon as count elements have been collected, so preceding lazy operations never process the rest of the input.
Parameters
The number of elements to take from the front of the array. A negative count follows es-toolkit's take and drops from the end instead.
Returns
A function that maps a readonly T[] to a new T[] with at most count elements.
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.