0.1.1 • Published 3 years ago

@annexe/array.head v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@annexe/head

A function that returns the first element as an array and optionally to a specified index. You can also provide an index to where you want it to stop at as a second argument.

Usage

import { head } from '@annexe/head';

const myArray = [1, 2, 3, 4, 5];
console.log(head<number>(myArray)); // logs [1]
console.log(head<number>(myArray, 2)); // logs [1, 2]