
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
easy-reducer
Advanced tools
Easier reducers with less boilerplate.
Easy reducers generates action creators and types, and makes your reducers reusable.
npm install --save easy-reducer
import easyReducerCreator from 'easy-reducer'
import { createStore, applyMiddleware, combineReducers } from 'redux'
import thunk from 'redux-thunk'
const defaultState = {
test: 'data'
}
const syncActions = {
// previous state is always the last argument.
testDataPlusNum (num, state) {
return {...state, test: 'data' + num}
},
testDataPlusTwoNum (num1, num2, state) {
return {...state, test: 'data' + num1 + '' + num2}
}
}
// async actions are handled differently, and are meant to be used with redux-thunk
const asyncActions = {
// syncActions, dispatch, getState (from thunk), are always the last arguments.
asyncStateModifyer (num, syncActions, dispatch, getState) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(dispatch(syncActions.testDataPlusNum(num)))
}, 20)
})
},
}
const testReducerCreator = easyReducerCreator(defaultState, syncActions, asyncActions)
// testReducer1 now has all the action creators you would use for your methods, with the types TR1/methodName
export const testReducer1 = testReducerCreator('TR1')
// generated types as constants for reference with RXJS epics or whatever
// EG: {testDataPlusNum: 'TR1/testDataPlusNum', testDataPlusTwoNum: 'TR1/testDataPlusTwoNum'}
console.log(testReducer1.TYPES)
// Reducers are reusable with different ID's
export const testReducer2 = testReducerCreator('TR2')
export const store = createStore(combineReducers({
// a reducer property is attached, which serves as the actual reducer.
testReducer1: testReducer1.reducer,
testReducer2: testReducer2.reducer
}), undefined, applyMiddleware(thunk))
store.dispatch(testReducer1.testDataPlusNum(1))
store.dispatch(testReducer1.asyncStateModifyer(2))
.then(() => store.dispatch(testReducer2.testDataPlusTwoNum(3, 4)))
FAQs
Easy reducers with less boilerplate
The npm package easy-reducer receives a total of 2 weekly downloads. As such, easy-reducer popularity was classified as not popular.
We found that easy-reducer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.