# redux-duplicate-actions

> This is a redux middleware that detects duplicate actions & shows this in the console. You can choose to make them fatal errors or friendly warnings! Development use only!

Latest version **3.0.2** (published 2023-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-duplicate-actions
pnpm add redux-duplicate-actions
yarn add redux-duplicate-actions
bun add redux-duplicate-actions
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2023-08-17 |
| First published | 2017-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 15 |
| Unpacked size | 27.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 11 |
| Author | David Makuni |
| Maintainers | daviemakz |
| Keywords | redux, flux, middleware, redux-middleware, dispatch, duplicate, actions |

## Links

- npm: https://www.npmjs.com/package/redux-duplicate-actions
- Repository: https://github.com/daviemakz/redux-duplicate-actions
- Homepage: https://github.com/daviemakz/redux-duplicate-actions#readme
- Issues: https://github.com/daviemakz/redux-duplicate-actions/issues
- npm.io page: https://npm.io/package/redux-duplicate-actions

## Dependencies (15)

- [md5](https://npm.io/package/md5.md) ^2.2.1
- [chai](https://npm.io/package/chai.md) ^4.2.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [rimraf](https://npm.io/package/rimraf.md) ^3.0.0
- [farmhash](https://npm.io/package/farmhash.md) ^3.0.0
- [hash-sum](https://npm.io/package/hash-sum.md) ^2.0.0
- [prettier](https://npm.io/package/prettier.md) 3.0.1
- [@babel/cli](https://npm.io/package/@babel/cli.md) ^7.13.14
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.13.14
- [circular-json](https://npm.io/package/circular-json.md) ^0.5.9
- [@babel/register](https://npm.io/package/@babel/register.md) ^7.13.14
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.13.12
- [console-log-colors](https://npm.io/package/console-log-colors.md) ^0.4.0
- [fast-json-stringify](https://npm.io/package/fast-json-stringify.md) ^2.0.0
- [@types/circular-json](https://npm.io/package/@types/circular-json.md) ^0.4.0

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 3.0.2 (latest) — 2023-08-17
- 3.0.0 — 2023-08-15
- 2.0.3 — 2021-03-30
- 2.0.2 — 2021-03-30
- 2.0.1 — 2021-03-30
- 2.0.0 — 2019-10-12
- 1.3.5 — 2019-05-23
- 1.3.4 — 2019-01-21
- 1.3.3 — 2019-01-21
- 1.3.2 — 2019-01-18
- 1.3.1 — 2019-01-08
- 1.3.0 — 2018-06-24
- 1.2.11 — 2018-06-24
- 1.2.10 — 2018-04-30
- 1.2.9 — 2018-04-10
- … 19 more at https://npm.io/package/redux-duplicate-actions/versions

## README

<p align="left">
<a href="https://www.npmjs.com/package/redux-duplicate-actions" target="_blank"><img src="https://img.shields.io/npm/v/redux-duplicate-actions" alt="npm"/></a>
<a href="https://www.npmjs.com/package/redux-duplicate-actions" target="_blank"><img src="https://img.shields.io/npm/dm/redux-duplicate-actions.svg" alt="Downloads"/></a>
<a href="https://github.com/daviemakz/redux-duplicate-actions/issues" target="_blank"><img src="https://img.shields.io/github/issues/daviemakz/redux-duplicate-actions" alt="GitHub issues"/></a>
<a href="https://github.com/daviemakz/redux-duplicate-actions/pulls" target="_blank"><img src="https://img.shields.io/github/issues-pr/daviemakz/redux-duplicate-actions" alt="GitHub pull requests"/></a>
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fdaviemakz%2Fredux-duplicate-actions?ref=badge_shield" target="_blank"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdaviemakz%2Fredux-duplicate-actions.svg?type=shield" alt="FOSSA Status"/></a>
<a href="https://www.npmjs.com/package/redux-duplicate-actions" target="_blank"><img src="https://img.shields.io/npm/l/redux-duplicate-actions" alt="NPM"/></a>
</p>

# Redux Duplicate Action Monitor

This is a redux middleware that detects duplicate actions &amp; shows this in the console. Ideal for ensuring good redux practices. Development use only!

If there is a duplicate action you will see this in the browser console:

```
[redux-duplicate-actions] A duplicate action has been detected.
[redux-duplicate-actions] Unique action hash: e6d0f668
[redux-duplicate-actions] Unpacked action: {type: 'SET_DATA', payload: {…}}
[redux-duplicate-actions] Original action: {type: 'SET_DATA', payload: ƒ} // Read below
```

If your payload is a function the middleware we will attempt to unpack it and show you the actual data. It does this by simply running the function against `store.getState()`. So effectively `action.payload(store.getState())`. If this fails it will do the comparison as normal.

_Supports Node 10.x +_

### Installation

Run this in the terminal:

```bash
npm install --save-dev redux-duplicate-actions
```

or

```bash
yarn add -D redux-duplicate-actions
```

## Usage

Supported options:

`fatal` (type: boolean) - if `true`, will throw an error when a duplicate action is detected. Default is `false`.

`logLevel` (type: 'log' | 'warn' | 'error') - the level of logging to the console. Default is `"warn"`.

`payloadKey` (type: string) - the key to use to get the payload for the redux action. Default is `"payload"`.

`unpackPayloadIfFunction` (type: boolean) - if true, will attempt to unpack the payload if it is a function. Default is `true`.

```js
if (__DEV__) {
  // To thrown fatal error on duplicate action
  const reduxDuplicateActions = require("redux-duplicate-actions")({
    fatal: true,
  });
  reduxMiddleware.push(reduxDuplicateActions);

  // To log duplicate action as warning
  const reduxDuplicateActions = require("redux-duplicate-actions")({
    fatal: false
  });
  reduxMiddleware.push(reduxDuplicateActions);
}
```

## Test

Run the following commands to test the module:

`yarn install && yarn test`

## Contributing

All contributions are very welcome, please read my [CONTRIBUTING.md](https://github.com/daviemakz/redux-duplicate-actions/blob/master/CONTRIBUTING.md) first. You can submit any ideas as [pull requests](https://github.com/daviemakz/redux-duplicate-actions/pulls) or as [GitHub issues](https://github.com/daviemakz/redux-duplicate-actions/issues). If you'd like to improve code, please feel free!

## License

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdaviemakz%2Fredux-duplicate-actions.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdaviemakz%2Fredux-duplicate-actions?ref=badge_large)

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