UNPKG

typedash

Version:

modern, type-safe collection of utility functions

45 lines (44 loc) 1.38 kB
import { t as Many } from "./Many-bCNxekD7.cjs"; import { t as ObjectPath } from "./ObjectPath-CRdxsVAG.cjs"; import { Get } from "type-fest"; //#region src/functions/get/get.d.ts /** * Gets the value at path of object. * Allows accessing properties in unions of objects and getting undefined if the property is not present. * @param object The object to query. * @param path The path of the property to get. * @returns The value at path of object. * @example * ```ts * get({ a: 1, b: 2, c: 3 }, 'b') // 2 * get({ * name: "John Doe", * address: { * street: "123 Main St", * city: "Anytown", * } * }, 'address.city') // "Anytown" * ``` */ declare function get<T, Path extends ObjectPath<T>>(object: T, path: Path): Get<T, Path>; /** * Gets the value at path of object. * Allows accessing properties in unions of objects and getting undefined if the property is not present. * @param object The object to query. * @param path The path of the property to get. * @returns The value at path of object. * @example * ```ts * get({ * name: "John Doe", * address: { * street: "123 Main St", * city: "Anytown", * } * }, ['address', 'city']) // "Anytown" * ``` */ declare function get<T, Path extends Many<string>>(object: T, path: Path): Get<T, Path>; //#endregion export { get as t }; //# sourceMappingURL=get-K70Zj9Bl.d.cts.map