UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

22 lines (20 loc) 364 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/array/first.ts /** * `first(array)` * * Returns the first element of `array`, or `undefined` if the array is empty. * * ```ts * first([1, 2, 3, 4]); // 1 * ``` * * ```ts * pipe([1, 2, 3, 4], first()); // 1 * ``` */ const first = dfdlT((target) => { return target[0]; }, 1); //#endregion export { first };