UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

10 lines (7 loc) 260 B
import { getValueOr } from "./main.ts"; export function last(str: string): string; export function last<A>(coll: A[]): A; export function last<A>(coll: A[] | string) { const cc = getValueOr([], coll); return cc.length === 0 ? null : cc[cc.length - 1]; }