# @writetome51/array-get-and-remove-adjacent-to-value

> Function that removes and returns section of the array, starting with, or close to, a particular value

Latest version **1.0.8** (published 2019-04-14) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2019-04-14 |
| First published | 2018-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Steve Thompson |
| Maintainers | writetome51 |
| Keywords | array, content, get, remove, items |

## Links

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

## Dependencies (6)

- [error-if-not-integer](https://npm.io/package/error-if-not-integer.md) ~1.0.0
- [error-if-index-is-negative](https://npm.io/package/error-if-index-is-negative.md) ~1.0.1
- [@writetome51/array-get-indexes](https://npm.io/package/@writetome51/array-get-indexes.md) ~1.0.2
- [@writetome51/adjacent-to-value-info-interface](https://npm.io/package/@writetome51/adjacent-to-value-info-interface.md) ~1.0.2
- [@writetome51/array-get-and-remove-adjacent-at](https://npm.io/package/@writetome51/array-get-and-remove-adjacent-at.md) ~1.0.5
- [error-if-index-not-valid-after-offset-was-added](https://npm.io/package/error-if-index-not-valid-after-offset-was-added.md) ~1.0.0

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 1.0.8 (latest) — 2019-04-14
- 1.0.7 — 2019-03-31
- 1.0.6 — 2019-02-24
- 1.0.5 — 2018-12-05
- 1.0.4 — 2018-11-06
- 1.0.3 — 2018-11-02
- 1.0.2 — 2018-10-26
- 1.0.1 — 2018-10-11
- 1.0.0 — 2018-09-28

## README

## getAndRemoveAdjacentToValue(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: anyExceptObject,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;offset: integer,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;howMany: integer_greater_than_zero<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array<br>): any[]

Removes and returns `howMany` adjacent items from `array`, starting with, or  
close to, `value`.  Exactly where the selection starts is decided by `offset`,  
which is the position, relative to `value`, where to begin removing.  
For example, if `offset` is 0, then the selection begins at `value`.  If -1,  
it begins one place to the left of `value`.  If 1, it begins one place to the  
right.  

Note: the function only works with the first found instance of `value`.

### Examples
```
let array = [1,3,5,7,9,11,13,15,17];
let result = getAndRemoveAdjacentToValue(
    {value: 7, offset: 0, howMany: 3},
    array
);
// result is now [7, 9, 11] .
// array is now [1, 3, 5, 13, 15, 17].
// If offset was 2, for example, result would be [11, 13, 15]


let array = [1,3,5,7,9,11,13,15,17];
let result = getAndRemoveAdjacentToValue(
    {value: 13, offset: -2, howMany: 4},
    array
);
// result is now [9, 11, 13, 15] .
// array is now [1,3,5,7,17].
```

### Installation
`npm i  @writetome51/array-get-and-remove-adjacent-to-value`

### Loading
```
// if using TypeScript:
import {getAndRemoveAdjacentToValue} 
    from '@writetome51/array-get-and-remove-adjacent-to-value';
    
// if using ES5 JavaScript:
var getAndRemoveAdjacentToValue = 
    require('@writetome51/array-get-and-remove-adjacent-to-value').getAndRemoveAdjacentToValue;
```

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