# @writetome51/array-get-unique-items

> Returns every item in array without any duplicates

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

## Install

```sh
npm install @writetome51/array-get-unique-items
pnpm add @writetome51/array-get-unique-items
yarn add @writetome51/array-get-unique-items
bun add @writetome51/array-get-unique-items
```

## 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.0.2 |
| Published | 2020-09-08 |
| First published | 2018-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Steve Thompson |
| Maintainers | writetome51 |
| Keywords | array, get, unique, items, no-duplicates, manipulation |

## Links

- npm: https://www.npmjs.com/package/@writetome51/array-get-unique-items
- Repository: https://github.com/writetome51/array-get-unique-items
- Homepage: https://github.com/writetome51/array-get-unique-items#readme
- Issues: https://github.com/writetome51/array-get-unique-items/issues
- npm.io page: https://npm.io/package/@writetome51/array-get-unique-items

## Dependencies (2)

- [@writetome51/not](https://npm.io/package/@writetome51/not.md) >=2.0.0
- [@writetome51/array-has](https://npm.io/package/@writetome51/array-has.md) >=2.0.2

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2020-09-08
- 2.0.1 — 2020-08-15
- 2.0.0 — 2020-08-04
- 1.1.3 — 2019-04-14
- 1.1.2 — 2019-02-26
- 1.1.1 — 2018-12-07
- 1.1.0 — 2018-11-13
- 1.0.3 — 2018-10-25
- 1.0.2 — 2018-10-22
- 1.0.1 — 2018-10-11

## README

# getUniqueItems(array): any[]

Returns every item in `array` without any duplicates. Does not modify `array`. 

Note:  duplicate arrays do not have to match using the `===` operator.  
However, duplicate objects do.  See the examples.


## Examples
<details>
<summary>view examples</summary>

```
getUniqueItems( [ '', 1, 2, 3, '', 1, 2, 3, '' ] );  
// --> [ '', 1, 2, 3 ]

getUniqueItems( [ true, true, false, true, false, 'aa' ] );  
// --> [ true, false, 'aa' ]


// Objects appearing identical, but not identical in memory, are not 
// considered duplicates:

let obj1 = {name: 'steve'};
let obj2 = {name: 'steve'};

getUniqueItems([obj1, obj2]);
// --> [ {name: 'steve'}, {name: 'steve'} ]

// Try this:

let obj1 = {name: 'steve'};
let obj2 = obj1;

getUniqueItems([obj1, obj2]);
// --> [ {name: 'steve'} ]


// Arrays appearing identical, but not identical in memory, can still 
// be considered duplicates. This is because the algorithm loops thru 
// them, checking if array1[i] === array2[i].  If array1[i] and array2[i] 
// are both arrays of identical length, the algorithm recursively operates 
// on those arrays.

getUniqueItems( [ [[1,2,3]], [[1,2,3]] ] );
// --> [ [[1,2,3]] ]


// But, if the arrays contain objects not identical in memory, they're not 
// considered duplicates:

let arr = [ [[{name: 'steve'}]], [[{name: 'steve'}]] ];

getUniqueItems(arr);
// --> [ [[{name: 'steve'}]], [[{name: 'steve'}]] ]

// Let's try that again with objects identical in memory:

let obj1 = {name: 'steve'};
let obj2 = obj1;
let arr = [ [[obj1]], [[obj2]] ];
getUniqueItems(arr);
// --> [ [[{name: 'steve'}]] ]
```
</details>

## Installation
`npm i  @writetome51/array-get-unique-items`

## Loading
```js
import {getUniqueItems} from '@writetome51/array-get-unique-items';
```

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