mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-03 02:21:49 +08:00
c72679e4e9
* refactor(components): refactor form * refactor: resolve PR comments * refactor(components): refactor isNested * refactor: resolve PR comments
23 lines
577 B
TypeScript
23 lines
577 B
TypeScript
import { get, set } from 'lodash-unified'
|
|
import type { Entries } from 'type-fest'
|
|
import type { Arrayable } from '.'
|
|
|
|
export const keysOf = <T>(arr: T) => Object.keys(arr) as Array<keyof T>
|
|
export const entriesOf = <T>(arr: T) => Object.entries(arr) as Entries<T>
|
|
export { hasOwn } from '@vue/shared'
|
|
|
|
export const getProp = <T = any>(
|
|
obj: Record<string, any>,
|
|
path: Arrayable<string>,
|
|
defaultValue?: any
|
|
): { value: T } => {
|
|
return {
|
|
get value() {
|
|
return get(obj, path, defaultValue)
|
|
},
|
|
set value(val: any) {
|
|
set(obj, path, val)
|
|
},
|
|
}
|
|
}
|