Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
reducer-composer
Advanced tools
Compose your reducers effortlessly, with intellisense and strict type-checking.
import {
createReducer,
createCombinedReducer,
createReducerSequence,
createBatchReducer,
createKeyedReducer,
createReducerCrudHandlers,
createReducerOnAction,
ActionOfReducer,
ignore
} from "reducer-composer";
interface User {
id: string;
name: string;
birth: Date;
}
const user = createReducer<User>()({
USER_CHANGE_NAME(user, { name }: { name: string }) {
return { ...user, name };
},
USER_CHANGE_BIRTH(user, { birth }: { birth: Date }) {
return { ...user, birth };
}
});
const click = createReducer<number>()({
CLICK(clicks) {
return clicks + 1;
},
CLICK_SET(_, { clicks }: { clicks: number }) {
return clicks;
}
});
const userClick = createCombinedReducer({
user,
click
});
const userClickBatchReducer = createBatchReducer("CLICKS", userClick);
const usersReducer = createKeyedReducer("id", user);
const companyUsers = createReducerSequence(
usersReducer,
createReducer<Record<string, User>>()({
USER_ADD(state, user: User) {
return { ...state, [user.id]: user };
}
})
);
const usersCounter = createReducerOnAction<
number,
ActionOfReducer<typeof companyUsers>
>()({
USER_ADD(count) {
return count + 1;
},
USER_CHANGE_BIRTH: ignore,
USER_CHANGE_NAME: ignore
});
interface Car {
id: string;
name: string;
km: number;
}
const carCrud = createReducerCrudHandlers(
(payload: Car) => [payload.id, payload],
(payload: { id: string }) => payload.id
);
const car = createReducer<Record<string, Car>>()({
CAR_ADD: carCrud.create,
CAR_UPDATE: carCrud.update,
CAR_DESTROY: carCrud.discard
});
[ ] remove deprecated methods [ ] change createReducer signature in favor of createHandlers [ ] documentation [ ] dtslint tests [ ] jest tests [ ] performance tests
FAQs
utilities for composing reducers
The npm package reducer-composer receives a total of 1 weekly downloads. As such, reducer-composer popularity was classified as not popular.
We found that reducer-composer 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.