UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

23 lines (22 loc) 877 B
/** * You can use this `get` function to retrieve a nested property from an object by chaining * the keys with dots in the `path` parameter. For example: * ```typescript * const obj = { * foo: { * bar: { * baz: 'Hello, World!' * } * } * }; * * console.log(get(obj, 'foo.bar.baz')); // Output: 'Hello, World!' * console.log(get(obj, 'foo.bar.baz', 'Default')); // Output: 'Hello, World!' * console.log(get(obj, 'foo.bar.qux', 'Default')); // Output: 'Default' * ``` * @param obj the object to retrieve the nested property from * @param path the path to the nested property * @param defaultValue the default value to return if the nested property does not exist * @returns the nested property if it exists, otherwise the default value */ export declare function get<T, K>(obj: T, path: string, defaultValue?: K): any;