Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
redux-collector
Advanced tools
Easy Collection Reducers for Redux.
http://redux-collector.mediadrake.com/
% npm install redux-collector
Redux Collector is a Reducer Generator for Collections
import { createStore } from 'redux';
import collectify from 'redux-collector';
function counterReducer(state = 0, action) {
switch(action.type) {
case 'INCREMENT':
return state + 1;
case 'DECRAMENT':
return state - 1;
default:
return state;
}
}
export default createStore(
collectify(
counterReducer,
{
add: 'ADD_ITEM',
hydrate: 'HYDRATE_ITEMS',
remove: 'REMOVE_ITEM'
}
)
);
Then call actions using the types you created with collectify.
import store from './MyStore'
const {dispatch, subscribe, getState} = store;
subscribe(val => console.log('State is:', getState()));
dispatch({
type: 'HYDRATE_ITEMS',
data: [1, 2, 3, 4]
});
// State is : [1, 2, 3, 4]
dispatch({
type: 'ADD_ITEM',
data: 5
});
// State is : [1, 2, 3, 4, 5]
dispatch({
type: 'INCREMENT'
});
// State is : [2, 3, 4, 5, 6]
dispatch({
type: 'DECREMENT',
query: item => item >= 5
});
// State is : [1, 2, 3, 3, 4]
dispatch({
type: 'REMOVE',
query: item => item < 3
});
// State is : [3, 3, 4]
dispatch({
type: 'REMOVE',
limit: 2,
order: -1
});
// State is : [3]
The above reducers can actually be a whole lot shorter.
import { createStore } from 'redux';
import collectify from 'redux-collector';
export default createStore(
collectify(
{
defaultsTo: 0,
"INCREMENT": state => state + 1,
"DECRAMENT": state => state - 1
},
{
add: 'ADD_ITEM',
hydrate: 'HYDRATE_ITEMS',
remove: 'REMOVE_ITEM'
}
)
);
This is courtesy of Reducify. Head over to their documentation and check out all the ways you can make reducers. Any argument you pass to collectify gets automatically passed to reducify.
Redux Collector is free software under the MIT license. It was created in sunny Santa Monica by Matthew Drake.
FAQs
Easy Collection Reducers for Redux
The npm package redux-collector receives a total of 1 weekly downloads. As such, redux-collector popularity was classified as not popular.
We found that redux-collector 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.