Skip to content

Commit 5594170

Browse files
authored
feat: remove lodash (#784)
1 parent e803b22 commit 5594170

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

Diff for: .size-limit

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
{
99
"path": "dist/index.js",
10-
"limit": "9.5 KB",
10+
"limit": "1.5 KB",
1111
"import": "Chart"
1212
},
1313
{
@@ -18,7 +18,7 @@
1818
},
1919
{
2020
"path": "dist/index.modern.js",
21-
"limit": "9.5 KB",
21+
"limit": "1.5 KB",
2222
"import": "Chart"
2323
}
2424
]

Diff for: package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141
"release": "standard-version",
4242
"cleanPublish": "yarn test && clean-publish"
4343
},
44-
"dependencies": {
45-
"lodash": "^4.17.19"
46-
},
44+
"dependencies": {},
4745
"peerDependencies": {
4846
"chart.js": "^3.5.0",
4947
"react": "^16.8.0 || ^17.0.0"

Diff for: src/chart.tsx

+8-9
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import React, {
99
import type { Ref, MouseEvent } from 'react';
1010
import ChartJS from 'chart.js/auto';
1111
import type { ChartData, ChartType, DefaultDataPoint } from 'chart.js';
12-
import merge from 'lodash/merge';
13-
import assign from 'lodash/assign';
14-
import find from 'lodash/find';
1512

1613
import { Props, ChartJSOrUndefined, TypedChartComponent } from './types';
1714

@@ -49,7 +46,7 @@ function ChartComponent<
4946
: {
5047
datasets: [],
5148
};
52-
} else return merge({}, data);
49+
} else return data;
5350
}, [data, canvas.current]);
5451

5552
const [chart, setChart] = useState<TypedChartJS>();
@@ -125,12 +122,11 @@ function ChartComponent<
125122
const { datasets: currentDataSets = [] } = chart.config.data;
126123

127124
// copy values
128-
assign(chart.config.data, newChartData);
125+
Object.assign(chart.config.data, newChartData);
129126

130127
chart.config.data.datasets = newDataSets.map((newDataSet: any) => {
131128
// given the new set, find it's current match
132-
const currentDataSet = find(
133-
currentDataSets,
129+
const currentDataSet = currentDataSets.find(
134130
d => d.label === newDataSet.label && d.type === newDataSet.type
135131
);
136132

@@ -146,10 +142,13 @@ function ChartComponent<
146142
}
147143

148144
// copy in values
149-
assign(currentDataSet.data, newDataSet.data);
145+
Object.assign(currentDataSet.data, newDataSet.data);
150146

151147
// apply dataset changes, but keep copied data
152-
assign(currentDataSet, { ...newDataSet, data: currentDataSet.data });
148+
Object.assign(currentDataSet, {
149+
...newDataSet,
150+
data: currentDataSet.data,
151+
});
153152
return currentDataSet;
154153
});
155154

0 commit comments

Comments
 (0)