element-plus/packages/utils/objects.ts
Jungzl 7bba5332f1
chore: update dependencies (#18573)
* chore: update dependencies

typescript: v5.5
vue-tsc: v2
eslint: v8-latest
@commitlint/*: v18

* fix: apply suggestions

* fix: ignore some ts errors
2024-10-29 10:01:58 +08:00

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)
},
}
}