UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

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