import { get, set } from 'lodash-es' import type { Entries } from 'type-fest' import type { Arrayable } from './typescript' export const entriesOf = (arr: T) => Object.entries(arr) as Entries export const getProp = ( obj: Record, path: Arrayable, defaultValue?: any ): { value: T } => { return { get value() { return get(obj, path, defaultValue) }, set value(val: any) { set(obj, path, val) }, } } const hasOwnProperty = Object.prototype.hasOwnProperty export const hasOwn = ( val: object, key: string | symbol ): key is keyof typeof val => hasOwnProperty.call(val, key) export const keysOf = (arr: T) => Object.keys(arr) as Array