@polgubau/utils
Version:
A collection of utility functions for TypeScript
31 lines (29 loc) • 838 B
text/typescript
/**
* Returns the first element of an array
* @param arr
* @returns the first element of the array
* @example first([1, 2, 3]) // 1
*/
declare function first<T>(arr: T[]): T | undefined;
/**
* Returns the last element of an array
* @param arr
* @returns the last element of the array
* @example last([1, 2, 3]) // 3
*/
declare function last<T>(arr: T[]): T | undefined;
/**
* Removes the first element of an array
* @param arr
* @returns a new array without the first element
* @example removeFirst([1, 2, 3]) // [2, 3]
*/
declare function removeFirst<T>(arr: T[]): T[];
/**
* Removes the last element of an array
* @param arr
* @returns a new array without the last element
* @example removeLast([1, 2, 3]) // [1, 2]
*/
declare function removeLast<T>(arr: T[]): T[];
export { first, last, removeFirst, removeLast };