# @writetome51/array-get-and-remove-adjacent-at

> Function removes and returns adjacent array items beginning at specified index

Latest version **3.0.2** (published 2021-11-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @writetome51/array-get-and-remove-adjacent-at
pnpm add @writetome51/array-get-and-remove-adjacent-at
yarn add @writetome51/array-get-and-remove-adjacent-at
bun add @writetome51/array-get-and-remove-adjacent-at
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2021-11-02 |
| First published | 2018-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Steve Thompson |
| Maintainers | writetome51 |
| Keywords | array, manipulation, remove, get, adjacent, items, data |

## Links

- npm: https://www.npmjs.com/package/@writetome51/array-get-and-remove-adjacent-at
- Repository: https://github.com/writetome51/array-get-and-remove-adjacent-at
- Homepage: https://github.com/writetome51/array-get-and-remove-adjacent-at#readme
- Issues: https://github.com/writetome51/array-get-and-remove-adjacent-at/issues
- npm.io page: https://npm.io/package/@writetome51/array-get-and-remove-adjacent-at

## Dependencies (1)

- [@writetome51/validate-adjacent-items-operation-args](https://npm.io/package/@writetome51/validate-adjacent-items-operation-args.md) >=0.0.1

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2021-11-02
- 3.0.1 — 2021-11-01
- 3.0.0 — 2021-05-01
- 2.0.0 — 2020-08-05
- 1.0.5 — 2019-03-31
- 1.0.4 — 2019-02-23
- 1.0.3 — 2018-12-05
- 1.0.2 — 2018-11-06
- 1.0.1 — 2018-10-11
- 1.0.0 — 2018-10-09

## README

# getAndRemoveAdjacentAt\<T\>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;startingIndex: number,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;howMany: number,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array: T[]<br>): T[]

Beginning at `startingIndex`, it removes and returns `howMany` adjacent items from `array`.  
`startingIndex` can be positive or negative.  
Intended as a replacement for Array.prototype.splice() when removing items from `array`.  
This does strict validation for all 3 parameters.


## Examples
```js
let arr = [1,2,3,4,5,6];
getAndRemoveAdjacentAt(1, 3, arr);
// --> [2,3,4]
// arr is now [1,5,6]

arr = [1, 2, 3, 4, 5, 6, 7, 8];
getAndRemoveAdjacentAt(-4, 2, arr);
// --> [5,6]
// arr is now [1,2,3,4,7,8].

arr = [1, 2, 3, 4, 5, 6];
getAndRemoveAdjacentAt(-2, 3, arr); // requesting 1 too many items.
// Error: 'the array does not have enough items to fulfill your request'

getAndRemoveAdjacentAt(0, 1, []); // index 0 doesn't exist on empty array.
// 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-and-remove-adjacent-at`

## Loading
```js
import {getAndRemoveAdjacentAt} 
    from '@writetome51/array-get-and-remove-adjacent-at';
```

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