# @writetome51/array-get-head-tail

> Functions that return either a number of items from the beginning of the array, or the end

Latest version **2.0.1** (published 2021-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @writetome51/array-get-head-tail
pnpm add @writetome51/array-get-head-tail
yarn add @writetome51/array-get-head-tail
bun add @writetome51/array-get-head-tail
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2021-11-15 |
| First published | 2018-10-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Steve Thompson |
| Maintainers | writetome51 |
| Keywords | array, manipulation, return, beginning, end, slice, data |

## Links

- npm: https://www.npmjs.com/package/@writetome51/array-get-head-tail
- Repository: https://github.com/writetome51/array-get-head-tail
- Homepage: https://github.com/writetome51/array-get-head-tail#readme
- Issues: https://github.com/writetome51/array-get-head-tail/issues
- npm.io page: https://npm.io/package/@writetome51/array-get-head-tail

## Dependencies (1)

- [@writetome51/array-get-adjacent-at](https://npm.io/package/@writetome51/array-get-adjacent-at.md) >=2.0.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2021-11-15
- 2.0.0 — 2020-08-06
- 1.0.5 — 2019-02-25
- 1.0.4 — 2018-12-07
- 1.0.3 — 2018-11-13
- 1.0.2 — 2018-10-24
- 1.0.1 — 2018-10-15
- 1.0.0 — 2018-10-15

## README

# getHead<T>(numItems, array: T[]): T[]

Returns `numItems` from beginning of `array`.

# getTail<T>(numItems, array: T[]): T[]  

Returns `numItems` from end of `array`.

Neither function modifies `array`.  

## Examples
```js
let arr = ['h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'];

getHead(3, arr);  
// --> ['h', 'i', 'j']

getTail(3, arr);  
// --> ['m', n', 'o']

getHead(8, arr);
// --> ['h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']

getTail(8, arr);
// --> ['h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']
    
getHead(9, arr);
// Error: the array does not have enough items to fulfill your request

getTail(9, arr);
// Error: The entered index is not valid. Whether positive or negative, it exceeds 
// the index range of the array.
```

## Installation
`npm i  @writetome51/array-get-head-tail`


## Loading
```js
import {getHead, getTail} from '@writetome51/array-get-head-tail';
```

---
_Source: https://npm.io/package/@writetome51/array-get-head-tail · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
