Skip to content

Commit 07d0acb

Browse files
committed
refactor: replace lodash/assignWith with vanilla js
1 parent 937f845 commit 07d0acb

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"classnames": "^2.3.2",
2929
"dayjs": "^1.11.7",
3030
"deepmerge": "^4.3.1",
31-
"lodash": "^4.17.21",
3231
"nano-memoize": "^3.0.16",
3332
"rc-field-form": "~1.27.4",
3433
"rc-util": "^5.38.1",
@@ -101,6 +100,7 @@
101100
"jest-environment-jsdom": "^28.1.3",
102101
"jest-watch-typeahead": "^1.1.0",
103102
"less": "^4.1.3",
103+
"lodash": "^4.17.21",
104104
"lorem-ipsum": "^2.0.8",
105105
"lz-string": "^1.5.0",
106106
"mockdate": "^3.0.5",

Diff for: pnpm-lock.yaml

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/utils/with-default-props.tsx

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import assignWith from 'lodash/assignWith'
2-
31
export function mergeProps<A, B>(a: A, b: B): B & A
42
export function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A
53
export function mergeProps(...items: any[]) {
6-
function customizer(objValue: any, srcValue: any) {
7-
return srcValue === undefined ? objValue : srcValue
8-
}
9-
10-
let ret = { ...items[0] }
11-
for (let i = 1; i < items.length; i++) {
12-
ret = assignWith(ret, items[i], customizer)
13-
}
4+
const ret: any = {}
5+
items.forEach(item => {
6+
Object.keys(item).forEach(key => {
7+
if (item[key] !== undefined) {
8+
ret[key] = item[key]
9+
}
10+
})
11+
})
1412
return ret
1513
}

0 commit comments

Comments
 (0)