# array-toggle

> Return an Array with a value included/removed, with optional forcing.

Latest version **1.0.3** (published 2018-10-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install array-toggle
pnpm add array-toggle
yarn add array-toggle
bun add array-toggle
```

## 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.0.3 |
| Published | 2018-10-12 |
| First published | 2018-10-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Guillaume VanderEst |
| Maintainers | gvanderest |
| Keywords | array, toggle |

## Links

- npm: https://www.npmjs.com/package/array-toggle
- Repository: https://github.com/gvanderest/array-toggle
- Homepage: https://github.com/gvanderest/array-toggle#readme
- Issues: https://github.com/gvanderest/array-toggle/issues
- npm.io page: https://npm.io/package/array-toggle

## Recent versions

- 1.0.3 (latest) — 2018-10-12
- 1.0.2 — 2018-10-12
- 1.0.1 — 2018-10-12
- 1.0.0 — 2018-10-12

## README

# arrayToggle

Return an Array with a value included/removed, with optional forcing.

I made this function because I found one of the most annoying situations I've
run into with Arrays, is toggling values.. but also being able to force whether
the value stays present or not.

Example:
```typescript
import arrayToggle from "array-toggle";

const list = [1, 2, 3];
const toggled = arrayToggle(list, 2);

console.log(toggled);
# [1, 3]
```

The third argument of arrayToggle allows forcing the value's state within the
Array, in an event where its membership may be governed by some other value,
such as a checkbox being checked or not.

Example:
```typescript
import arrayToggle from "array-toggle";

const list = [1, 2, 3];
const toggled = arrayToggle(list, 2, true);

console.log(toggled);
# [1, 2, 3]
```

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