# compact-func

> NPM project which simplifies filter and map functions

Latest version **1.0.0** (published 2022-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install compact-func
pnpm add compact-func
yarn add compact-func
bun add compact-func
```

## 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.0 |
| Published | 2022-07-04 |
| First published | 2022-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aryse |
| Maintainers | medic1111 |

## Links

- npm: https://www.npmjs.com/package/compact-func
- npm.io page: https://npm.io/package/compact-func

## Recent versions

- 1.0.0 (latest) — 2022-07-04

## README

# FUNCTION-FACILITATOR

## METHODS:

1. Filter
2. Map

```
const compactFunc = require("compact-func");

let equal = compactFunc.returnEqualItemInArr([1, 2, 3], 3);
console.log(equal); //output: [3]
```

### returnEqualItemInArr(arr, target)

Function that filters through an array (first argument) of items and returns the match to parameter passed (second argument):

> USAGE EXAMPLE:

```
console.log(returnEqualItemInArr(["one", "two", "three"], "two"));

```

- Output: [ 'two' ]

### returnNotEqualItemInArr(arr, target)

Function that filters through an array (first argument) of items and returns all BUT the match to parameter passed (second argument):

> USAGE EXAMPLE:

```
console.log(returnNotEqualItemInArr(["one", "two", "three"], "two"));
```

- Output: [ 'one', 'three' ]

### returnObjEqualInArr(arr, par, target)

Function that filters through an array of objects (first argument) and returns the match to target parameter passed (Third argument). The second argument is the 'key' property of the object:

> USAGE EXAMPLE:

```
console.log(
  returnObjEqualInArr(
    [{ name: "one" }, { name: "two" }, { name: "three" }],
    "name",
    "two"
  )
);
```

- Output: [ { name: 'two' } ]

### returnObjNotEqualInArr(arr, par, target)

Function that filters through an array of objects (first argument) and returns all BUT the match to target parameter passed (Third argument). The second argument is the 'key' property of the object:

> USAGE EXAMPLE:

```
console.log(
  returnObjNotEqualInArr(
    [{ name: "one" }, { name: "two" }, { name: "three" }],
    "name",
    "two"
  )
);
```

- Output: [ { name: 'one' }, { name: 'three' } ]

### copyOriginalArrAndDoThisToEach(arr, doFunc)

Function that Maps through an array (first argument) and returns a copy of the original array after running the function passed (second argument).

> USAGE EXAMPLE:

```
console.log(copyOriginalArrAndDoThisToEach([1, 2, 3], (item) => item * 2));
```

- Output: [ 2, 4, 6 ]

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