vuestic-ui
Version:
Vue 3 UI Framework
19 lines (18 loc) • 511 B
TypeScript
type FindByKey<T, Key extends string | number | symbol> = Key extends `${infer K}.${infer R}` ? K extends keyof T ? FindByKey<T[K], R> : never : Key extends keyof T ? T[Key] : never;
/**
* Access object by string path
*
* @example
*
* ```
* const obj = {
* user: {
* name: 'Maksim'
* }
* }
*
* getByPath(obj, 'user.name') // 'Maksim'
* ```
*/
export declare const getByPath: <T, Key extends string | number | symbol>(obj: T, path: Key, defaultValue?: any) => FindByKey<T, Key>;
export {};