UNPKG

@prelude/array

Version:

Array module.

14 lines (12 loc) 278 B
/** * @returns last element of an array. * @throws {TypeError} */ const last = <T>(values: T[]): T => { if (!values.length) { throw new TypeError('Expected non empty array to get last element.') } return values[values.length - 1] } export default last