Gathering detailed insights and metrics for typescript-fsa-immer
Gathering detailed insights and metrics for typescript-fsa-immer
Gathering detailed insights and metrics for typescript-fsa-immer
Gathering detailed insights and metrics for typescript-fsa-immer
typesafe redux reducers with 'immer' immutability in the box
npm install typescript-fsa-immer
Typescript
Module System
66.1
Supply Chain
82
Quality
74.8
Maintenance
100
Vulnerability
99.6
License
TypeScript (93.92%)
JavaScript (6.08%)
Total Downloads
13,050
Last Day
1
Last Week
4
Last Month
14
Last Year
90
5 Stars
5 Commits
1 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Mar 30, 2025
Minified
Minified + Gzipped
Latest Version
0.0.6
Package Id
typescript-fsa-immer@0.0.6
Unpacked Size
8.22 kB
Size
3.01 kB
File Count
14
Cumulative downloads
Total Downloads
Last Day
-50%
1
Compared to previous day
Last Week
0%
4
Compared to previous week
Last Month
-6.7%
14
Compared to previous month
Last Year
-4.3%
90
Compared to previous year
1
3
Redux reducer wrapped with immer produce for immutability.
Built on top of excellent typescript-fsa, fantastic immer, and inspired by the typescript-fsa-reducers library. With a goal to provide a fluent syntax for defining redux reducers with an "in the box" immutability provided by the immer "produce" function.
The classic approach to write a reducer with immer for immutability would look something like this:
1import {produce} from 'immer' 2 3const reducer = (state,action)=>{ 4 switch(action.type){ 5 case 'INCREMENT' 6 return produce(state,draft=>draft.counter++) 7 case 'SET_VALUE' 8 return produce(state,draft=>draft.counter=action.payload) 9 } 10}
Using this library, redux reducer is defined like this:
1import { immerReducer } from "typescript-fsa-immer"; 2import { actionCreatorFactory } from "typescript-fsa"; 3 4const actionCreator = actionCreatorFactory("COUNTER"); 5 6/*action creators*/ 7const increment = actionCreator("INCREMENT"); 8const decrement = actionCreator("DECREMENT"); 9const reset = actionCreator("RESET"); 10const setCounter = actionCreator<number>("SET_VALUE"); 11 12/*case handlers, the state here can be mutated safely! */ 13const onIncrement = state => state.counter++; 14const onDecrement = state => state.counter--; 15const onReset = state => (state.counter = 0); 16 17/*the payload for this action creator is strongly typed, must be a number or TS will complain*/ 18const onSetCounter = (state, payload: number) => (state.counter = payload); 19 20/* Compose the reducer, define case handler for every action creator. 21 * Everything is strongly typed and typesafe! 22 */ 23const reducer = immerReducer(initialState) 24 .case(increment, onIncrement) 25 .case(decrement, onDecrement) 26 .case(reset, onReset) 27 .case(setCounter, onSetCounter);
Reducer case handlers are wrapped with a immer "produce". The state object passed to the case handler is an immer "draft". The original state object is never mutated.
yarn add typescript-fsa-immer immer typescript-fsa
or
npm install typescript-fsa-immer immer typescript-fsa --save
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
48 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More