Remove lodash from instrument

This commit is contained in:
Nathan Bierema 2024-08-13 23:06:12 -04:00
parent 118a9fb1fa
commit 71b1261757
4 changed files with 25 additions and 27 deletions

View File

@ -40,10 +40,6 @@
"prepack": "pnpm run clean && pnpm run build",
"prepublish": "pnpm run type-check && pnpm run lint && pnpm run test"
},
"dependencies": {
"@babel/runtime": "^7.25.0",
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@babel/cli": "^7.24.8",
"@babel/core": "^7.25.2",
@ -52,7 +48,6 @@
"@babel/preset-env": "^7.25.3",
"@babel/preset-typescript": "^7.24.7",
"@types/jest": "^29.5.12",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.14",
"jest": "^29.7.0",
"redux": "^5.0.1",

View File

@ -1,6 +1,6 @@
import { difference, isPlainObject, union } from 'lodash-es';
import {
Action,
isPlainObject,
Observer,
Reducer,
Store,
@ -667,9 +667,18 @@ function liftReducerWith<
const actionIds = [];
for (let i = start; i < end; i++) actionIds.push(i);
if (active) {
skippedActionIds = difference(skippedActionIds, actionIds);
const actionIdsSet = new Set(actionIds);
skippedActionIds = skippedActionIds.filter(
(actionId) => !actionIdsSet.has(actionId),
);
} else {
skippedActionIds = union(skippedActionIds, actionIds);
const skippedActionIdsSet = new Set(skippedActionIds);
skippedActionIds = [
...skippedActionIds,
...actionIds.filter(
(actionId) => !skippedActionIdsSet.has(actionId),
),
];
}
// Optimization: we know history before this action hasn't changed
@ -694,7 +703,10 @@ function liftReducerWith<
}
case ActionTypes.SWEEP: {
// Forget any actions that are currently being skipped.
stagedActionIds = difference(stagedActionIds, skippedActionIds);
const skippedActionIdsSet = new Set(skippedActionIds);
stagedActionIds = stagedActionIds.filter(
(actionId) => !skippedActionIdsSet.has(actionId),
);
skippedActionIds = [];
currentStateIndex = Math.min(
currentStateIndex,

View File

@ -15,7 +15,6 @@ import {
LiftedState,
} from '../src/instrument';
import { from, Observable } from 'rxjs';
import _ from 'lodash';
type CounterAction = { type: 'INCREMENT' } | { type: 'DECREMENT' };
function counter(state = 0, action: CounterAction) {
@ -1171,13 +1170,15 @@ describe('instrument', () => {
function filterStackAndTimestamps<S, A extends Action<string>>(
state: LiftedState<S, A, null>,
) {
state.actionsById = _.mapValues(state.actionsById, (action) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delete action.timestamp;
delete action.stack;
return action;
});
state.actionsById = Object.fromEntries(
Object.entries(state.actionsById).map(([actionId, action]) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delete action.timestamp;
delete action.stack;
return [actionId, action];
}),
);
return state;
}

View File

@ -1819,13 +1819,6 @@ importers:
version: 5.0.4(webpack-cli@5.1.4)(webpack@5.93.0)
packages/redux-devtools-instrument:
dependencies:
'@babel/runtime':
specifier: ^7.25.0
version: 7.25.0
lodash-es:
specifier: ^4.17.21
version: 4.17.21
devDependencies:
'@babel/cli':
specifier: ^7.24.8
@ -1848,9 +1841,6 @@ importers:
'@types/jest':
specifier: ^29.5.12
version: 29.5.12
'@types/lodash-es':
specifier: ^4.17.12
version: 4.17.12
'@types/node':
specifier: ^20.14.14
version: 20.14.14