super-utils-plus
Version:
A superior alternative to Lodash with improved performance, TypeScript support, and developer experience
57 lines (56 loc) • 1.05 kB
TypeScript
/**
* Gets the first element of array.
*
* @param array - The array to query
* @returns The first element of array
*
* @example
* ```ts
* head([1, 2, 3]);
* // => 1
*
* head([]);
* // => undefined
* ```
*/
export declare function head<T>(array: T[]): T | undefined;
/**
* Gets the last element of array.
*
* @param array - The array to query
* @returns The last element of array
*
* @example
* ```ts
* last([1, 2, 3]);
* // => 3
* ```
*/
export declare function last<T>(array: T[]): T | undefined;
/**
* Gets all but the first element of array.
*
* @param array - The array to query
* @returns The slice of array
*
* @example
* ```ts
* tail([1, 2, 3]);
* // => [2, 3]
* ```
*/
export declare function tail<T>(array: T[]): T[];
/**
* Gets all but the last element of array.
*
* @param array - The array to query
* @returns The slice of array
*
* @example
* ```ts
* initial([1, 2, 3]);
* // => [1, 2]
* ```
*/
export declare function initial<T>(array: T[]): T[];
export declare const first: typeof head;