# custom-arr-methods

> Immutable custom array methods

Latest version **1.1.5** (published 2022-12-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install custom-arr-methods
pnpm add custom-arr-methods
yarn add custom-arr-methods
bun add custom-arr-methods
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2022-12-25 |
| First published | 2022-12-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | https://github.com/zhuraveln |
| Maintainers | zhuraveln |
| Keywords | immutable, custom, array, methods, insert, remove, replace, swap |

## Links

- npm: https://www.npmjs.com/package/custom-arr-methods
- Repository: https://github.com/zhuraveln/custom-arr-methods
- Homepage: https://github.com/zhuraveln/custom-arr-methods#readme
- Issues: https://github.com/zhuraveln/custom-arr-methods/issues
- npm.io page: https://npm.io/package/custom-arr-methods

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.1.5 (latest) — 2022-12-25
- 1.1.4 — 2022-12-25
- 1.1.3 — 2022-12-25
- 1.1.2 — 2022-12-25
- 1.1.1 — 2022-12-24
- 1.1.0 — 2022-12-24
- 1.0.0 — 2022-12-24

## README

# custom-arr-methods

Custom immutable array's methods for different scenarios

All methods returned a new array

Also available all default mutable array's methods to immutable [immutable-arr-methods](https://www.npmjs.com/package/immutable-arr-methods)

## Installation

```bash
npm install custom-arr-methods
```

## Usage

**All methods have tooltips when you hover over them**
![tooltips-example](https://drive.google.com/uc?id=1AVGqbKJuDmajtsIpS2ex8ZT-oQB7UvQS)

### insert

Immutable insert element into array **by destination index**

```javascript
import { insert } from 'custom-arr-methods'

const i = [1, 2, 3, 4, 5]

const j = insert(i, 2, 42) // (array, destinationIndex, element)

console.log(i) // [1, 2, 3, 4, 5]
console.log(j) // [1, 2, 42, 3, 4, 5]
```

### removeOne

Immutable remove element from array **by element's index**

```javascript
import { removeOne } from 'custom-arr-methods'

const i = [1, 2, 3, 4, 5]

const j = removeOne(i, 2) // (array, index)

console.log(i) // [1, 2, 3, 4, 5]
console.log(j) // [1, 2, 4, 5]
```

### removeMultiple

Immutable remove elements from array **by element's indexes**

```javascript
import { removeMultiple } from 'custom-arr-methods'

const i = [1, 2, 3, 4, 5]

const j = removeMultiple(i, [0, 4]) // (array, indexes)

console.log(i) // [1, 2, 3, 4, 5]
console.log(j) // [2, 3, 4]
```

### replace

Immutable replace element in array **by element's index**

```javascript
import { replace } from 'custom-arr-methods'

const i = [1, 2, 3, 4, 5]

const j = replace(i, 2, 42) // (array, index, element)

console.log(i) // [1, 2, 3, 4, 5]
console.log(j) // [1, 2, 42, 4, 5]
```

### swapOne

Immutable change position for one element in array **by source and destination index**

```javascript
import { swapOne } from 'custom-arr-methods'

const i = [1, 2, 3, 4, 5]

const j = swapOne(i, 0, 4) // (array, sourceIndex, destinationIndex)

console.log(i) // [1, 2, 3, 4, 5]
console.log(j) // [2, 3, 4, 5, 1]
```

### swapTwo

Immutable swap positions for two elements in array **by element's indexes**

```javascript
import { swapTwo } from 'custom-arr-methods'

const i = [1, 2, 3, 4, 5]

const j = swapTwo(i, 0, 4) // (array, firstElementIndex, secondElementIndex)

console.log(i) // [1, 2, 3, 4, 5]
console.log(j) // [5, 2, 3, 4, 1]
```

---
_Source: https://npm.io/package/custom-arr-methods · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
