Skip to content

Commit

Permalink
feat: reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Dec 1, 2023
1 parent 5046bd0 commit f01584b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/components/form/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ export function isSafeSetRefComponent(component: any): boolean {
return !isSimpleFunctionComponent(component.type)
}

export function cloneByNamePathList(
export const cloneByNamePathList = (
store: Store,
namePathList: NamePath[]
): Store {
let newStore = {}
namePathList.forEach(namePath => {
const value = getValue(store, toArray(namePath))
newStore = setValue(newStore, toArray(namePath), value)
})

return newStore
): Store => {
return namePathList.reduce((accumulator, currentValue) => {
return setValue(
accumulator,
toArray(currentValue),
getValue(store, toArray(currentValue))
)
}, {})
}

0 comments on commit f01584b

Please sign in to comment.