Files
element-plus/packages/utils/objects.ts
Noblet Ouways 9c64744a3a chore: remove type-fest (#23002)
* chore: remove type-fest

* chore: apply suggestion

Co-authored-by: rzzf <cszhjh@gmail.com>

---------

Co-authored-by: rzzf <cszhjh@gmail.com>
2025-12-05 22:08:40 +08:00

25 lines
584 B
TypeScript

import { get, set } from 'lodash-unified'
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 [keyof T, T[keyof 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)
},
}
}