# @writetome51/array-replace-adjacent-at

> Replaces adjacent items in the array with same number of new adjacent items

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

## Install

```sh
npm install @writetome51/array-replace-adjacent-at
pnpm add @writetome51/array-replace-adjacent-at
yarn add @writetome51/array-replace-adjacent-at
bun add @writetome51/array-replace-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.1 |
| Published | 2021-11-15 |
| First published | 2018-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Steve Thompson |
| Maintainers | writetome51 |
| Keywords | array, splice, replace, adjacent, items, manipulation |

## Links

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

## Dependencies (1)

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

## Recent versions

- 3.0.1 (latest) — 2021-11-15
- 3.0.0 — 2021-11-01
- 2.0.0 — 2020-11-22
- 1.0.3 — 2019-04-14
- 1.0.2 — 2019-03-02
- 1.0.1 — 2018-11-20
- 1.0.0 — 2018-11-06

## README

# replaceAdjacentAt\<T\>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;startingIndex: number,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newValues: T[],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array: T[]<br>): void

Replaces adjacent items, beginning at `startingIndex`, with the same number  
of `newValues`, in `array`.  
`index` can be negative or positive. 


## Examples:
```js
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

replaceAdjacentAt(0, [20], arr);  
// arr is now  [ 20, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]

replaceAdjacentAt(0, [30, 31, 32, 33], arr);  
// arr is now  [ 30, 31, 32, 33, 5, 6, 7, 8, 9, 10 ]

replaceAdjacentAt(-3, [1, 2, 3], arr);
// arr is now  [ 30, 31, 32, 33, 5, 6, 7, 1, 2, 3 ]

// This works because the second arg has length greater than zero:
replaceAdjacentAt(-3, 'aaa', arr);
// arr is now  [ 30, 31, 32, 33, 5, 6, 7, 'a', 'a', 'a' ]

// This errors because the second arg has length of zero:
replaceAdjacentAt(0, [], arr);
// Error: 'Input must be integer greater than zero'

// This errors because arr only has 2 items left at index 8:
replaceAdjacentAt(8, ['a', 'b', 'c'], arr);
// Error: 'the array does not have enough items to fulfill your request'
```

## Installation
`npm i  @writetome51/array-replace-adjacent-at`


## Loading
```
import { replaceAdjacentAt } from '@writetome51/array-replace-adjacent-at';
```

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