UNPKG

vuestic-ui

Version:
24 lines (23 loc) 1.35 kB
type GetTypeByPath<T extends Record<string, any>, K extends string> = K extends keyof T ? T[K] : K extends `${infer TKey}.${infer Rest}` ? GetTypeByPath<T[TKey], Rest> : undefined; /** * Resolve the path to the target property inside the provided object. * * @param option - Object to look properties inside. * @param propsArray - Ordered array of strings, where each string should correspond to one of the property names at the current level of the object. */ export declare const getNestedValue: (option: Record<string, any>, propsArray: string[]) => any; /** * Finds value in the object using string with dots 'key.key.key' * * @param option - Object to look properties inside. * @param prop - String that contains a path to the property. */ export declare const getValueByPath: <Key extends string, T extends Record<string | Key, unknown>>(option: T, prop: string | Key) => GetTypeByPath<T, Key>; /** * Finds value of nested property inside an object. * * @param option - Object to look properties inside. * @param prop - String or function used to find nested property. */ export declare const getValueByKey: <Option extends Record<string, unknown>, R>(option: string | number | boolean | Option | ((...args: any[]) => any), prop: string | ((option: Option) => R)) => Option | R | GetTypeByPath<Option, string> | undefined; export {};