Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
entities-reducer
Advanced tools
This package is a high-order reducer that updates state using entities from normalizr.
By default, it expects the action to have a property of entities
or to follow the flux-standard-action
spec.
However, it is possible to pass a data resolver (see Parameters) if your case doesn't match either of those.
Why does this package exist?
One of the best things to store in redux is data from server requests. Additionally, working with items stored in redux is best done when the data is normalized. To simplify the storing of the data, this package will handle updating state with fresh normalized data.
Entities Reducer is a high-order reducer, which means it will accept more reducers for further customizations.
The custom reducers are passed directly to combineRecuders
from redux and should be passed into entities-reducers
with the same format.
npm install --save entities-reducer
--- or ---
yarn add entities-reducer
Then add to your root reducer:
import { combineReducers } from 'redux';
import entitiesReducer from 'entities-reducer';
const rootReducer = combineReducers({
entities: entitiesReducer({
/* custom reducers here */
}),
});
export default rootReducer;
entitiesReducer(reducers, { dataResolver })
Reducers are passed directly into combineReducers
from redux, after the entities have been updated in state. It is called with the updated state and immediately returned.
The data resolver is a lookup function that is passed the action and returns the entities object to use while updating.
If the data resolver returns a falsy value the entities-reducer
will skip process and move directly to handling the custom reducers.
Below is a customer dataResolver example, or you can checkout the default resolver.
Example
const customDataResolver = (action) => {
if (action.error) {
return false;
}
return action.data.extra.normalized;
}
FAQs
Redux normalized entity reducer
The npm package entities-reducer receives a total of 8 weekly downloads. As such, entities-reducer popularity was classified as not popular.
We found that entities-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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.