FSA-compliant camelize payload middleware for Redux
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
src
test
.babelrc
.eslintrc
.gitignore
README.md
package.json
yarn.lock

README.md

redux-camelize

CircleCI Codecov npm version License

FSA-compliant camelize payload middleware for Redux.

yarn add redux-camelize

# or

npm i redux-camelize

FSA-compliant

Using in combination with redux-actions.

Because it supports FSA actions, you can use this in combination with redux-actions.

Usage

import { createStore, applyMiddleware, compose } from 'redux'
import camelize from 'redux-camelize'

const store = createStore(
  rootReducer,
  initialState,
  applyMiddleware(camelize())
)

dispatch({
  type: 'RECIEVE_USER_ENTITY',
  payload: { user_id: 1, user_name: 'sugarshin' },
  meta: { camelize: true },
})

It's ignored on error.

Run on error

// You can use `ignoreOnError` option
const middleware = camelize({ ignoreOnError: false })

dispatch({
  type: 'RECIEVE_USER_ENTITY',
  payload: new Error('some error'),
  meta: { camelize: true },
})

You can import camelizer

import { camelizeKeys } from 'redux-camelize'
const subject = { f_o_o: 1, bar: { Buz: 3, Qu_x: [{ qu_uX: 4 }] } }
const expected = { fOO: 1, bar: { buz: 3, quX: [{ quUX: 4 }] } }
deepEqual(camelizeKeys(subject), expected)

License

MIT

© sugarshin