# @writetome51/array-remove-by-test

> Removes array items that match the criteria of a test function

Latest version **2.1.0** (published 2020-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @writetome51/array-remove-by-test
pnpm add @writetome51/array-remove-by-test
yarn add @writetome51/array-remove-by-test
bun add @writetome51/array-remove-by-test
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2020-09-09 |
| First published | 2019-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Steve Thompson |
| Maintainers | writetome51 |
| Keywords | array, manipulation, remove, filter, test, items |

## Links

- npm: https://www.npmjs.com/package/@writetome51/array-remove-by-test
- Homepage: https://github.com/writetome51/array-remove-by-test#readme
- npm.io page: https://npm.io/package/@writetome51/array-remove-by-test

## Dependencies (1)

- [@writetome51/array-get-and-remove-by-index](https://npm.io/package/@writetome51/array-get-and-remove-by-index.md) >=2.0.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2020-09-09
- 2.0.0 — 2020-09-07
- 1.0.0 — 2019-03-01

## README

# removeByTest(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test: (value, index?, array?) => boolean,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;useRemovedItem?: (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value, index?, array?<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;) => void<br>):  void

Removes any item in `array` that passes a `test`.  
If you use the optional callback `useRemovedItem()`, remember that this function   
removes items in descending index-order, i.e., item with index 0 is removed last.

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

removeByTest((item) => (item % 2) === 0,  arr);
console.log(arr);
// [1,3,5,7,9]

  
arr = [ [10, 2, 3], [2, 3, 4], 1, 6, false, [10, 20] ];

removeByTest(
    (item) => (Array.isArray(item) && item[0] === 10),
    arr
);
console.log(arr);
// [ [2, 3, 4], 1, 6, false ]


// Collect the indexes of removed items:

arr = [10, 1, 20, 2, 30, 3, 40, 4];

let found = [];
removeByTest(
    (value) => value >= 10, 
    arr, 
    (value, index) => found.push(index)
);
console.log(found);
// [ 6, 4, 2, 0 ] 
// (items removed in descending index-order)
```

## Installation
```bash
npm i @writetome51/array-remove-by-test
```

## Loading
```js
import {removeByTest} from '@writetome51/array-remove-by-test';
```

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