# unique-state

> Unique state is unique

Latest version **1.0.6** (published 2016-04-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install unique-state
pnpm add unique-state
yarn add unique-state
bun add unique-state
```

## 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.6 |
| Published | 2016-04-19 |
| First published | 2016-04-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ideal Life |
| Maintainers | ideal-life |
| Keywords | react, redux, state, unique state, unique-state |

## Links

- npm: https://www.npmjs.com/package/unique-state
- Repository: https://github.com/ideal-life/unique-state
- Homepage: https://github.com/ideal-life/unique-state/#readme
- Issues: https://github.com/ideal-life/unique-state/issues
- npm.io page: https://npm.io/package/unique-state

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2016-04-19
- 1.0.5 — 2016-04-19
- 1.0.4 — 2016-04-19
- 1.0.3 — 2016-04-19
- 1.0.1 — 2016-04-19
- 1.0.0 — 2016-04-19

## README

# unique-state

## Installation

```bash
$ npm install unique-state --save
```

## Usage

```js
import uniqueState from "unique-state"

const state = {
  str: "string",
  obj: {
    nl: null,
    bool: true
  },
  arr: [
    {
      numb: 5,
      obj: { }
    }
  ]
}

/*
  const state1 = {
    ...state,
    obj: {
      ...state.obj,
      str: "string"
    }
  }

  state1.obj !== state.obj // true

  state1.arr !== state.arr // false
*/

const state1 = uniqueState({
  ...state,
  obj: {
    ...state.obj,
    str: "string"
  }
})

state1.obj !== state.obj // true

state1.arr !== state.arr // true

/*
  const state2 = {
    ...state1,
    arr: [
      ...state1.arr,
      { nl: null }
    ]
  }

  state2.obj !== state1.obj // false

  state2.arr !== state1.arr // true

  state2.arr[0] !== state1.arr[0] // false

  state2.arr[0].obj !== state1.arr[0].obj // false
*/

const state2 = uniqueState({
  ...state1,
  arr: [
    ...state1.arr,
    { nl: null }
  ]
})

state2.obj !== state1.obj // true

state2.arr !== state1.arr // true

state2.arr[0] !== state1.arr[0] // true

state2.arr[0].obj !== state1.arr[0].obj // true
```

---

## See also

[![Freddie Gibbs - Cocaine Parties In L.A.](http://i.imgur.com/3oEmep8.jpg)](https://www.youtube.com/watch?v=lGaVPvWdxrU)

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