mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
7bba5332f1
* chore: update dependencies typescript: v5.5 vue-tsc: v2 eslint: v8-latest @commitlint/*: v18 * fix: apply suggestions * fix: ignore some ts errors
25 lines
611 B
TypeScript
25 lines
611 B
TypeScript
import { get, set } from 'lodash-unified'
|
|
import type { Entries } from 'type-fest'
|
|
import type { Arrayable } from '.'
|
|
|
|
export const keysOf = <T extends object>(arr: T) =>
|
|
Object.keys(arr) as Array<keyof T>
|
|
export const entriesOf = <T extends object>(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)
|
|
},
|
|
}
|
|
}
|