redux-camelize

3.0.0 • Public • Published

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

Package Sidebar

Install

npm i redux-camelize

Weekly Downloads

125

Version

3.0.0

License

MIT

Last publish

Collaborators

  • sugarshin