# redux-cond

> Redux reducer with cond function

Latest version **2.0.0** (published 2019-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-cond
pnpm add redux-cond
yarn add redux-cond
bun add redux-cond
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-11-01 |
| First published | 2017-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yue Yang |
| Maintainers | g1eny0ung |
| Keywords | redux, cond, reducer, helper |

## Links

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

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-11-01
- 1.1.6 — 2019-07-06
- 1.1.5 — 2019-04-28
- 1.1.4 — 2019-04-16
- 1.1.3 — 2019-03-30
- 1.1.2 — 2018-11-29
- 1.1.1 — 2018-01-18
- 1.1.0 — 2017-08-02
- 1.0.4 — 2017-07-19
- 1.0.3 — 2017-06-20
- 1.0.2 — 2017-05-31
- 1.0.1 — 2017-05-21
- 1.0.0 — 2017-05-18

## README

# redux-cond

[![Build Status](https://travis-ci.org/g1eny0ung/redux-cond.svg?branch=master)](https://travis-ci.org/g1eny0ung/redux-cond)
[![npm](https://img.shields.io/npm/v/redux-cond.svg?style=flat-square)](https://www.npmjs.com/package/redux-cond)

Redux reducer with cond function

## Installation

```sh
// or yarn add
npm i --save redux-cond
```

## Use

redux-cond inspired by [clojure cond](https://clojuredocs.org/clojure.core/cond)

Easy-to-use :smiley:

Return cond function in your reducer

```js
// const cond = require('redux-cond')
import cond from 'redux-cond'

function reducer(state, action) {
  return cond(
    type1, f1,
    type2, f2,
    ...
  )(state, action)
}
```

e.g.

```js
import cond from 'redux-cond'

const initialState = {
  count: 0
}

cond(
  'INCREMENT', state => Object.assign(state, { count: state.count + 1 }),
  'DECREMENT', state => Object.assign(state, { count: state.count - 1 })
)(initialState, { type: 'INCREMENT' }) // => { count: 1 }
```

**f (f1, f2, ...)** is a function which receive two arguments, state and action.

```js
const f = (state, action) => { return newState }
```

## License

MIT &copy; [g1eny0ung](https://github.com/g1eny0ung)

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