import { GetFieldType } from '../_internal/GetFieldType.js'; import { PropertyPath } from '../_internal/PropertyPath.js'; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey * @param {TObject} object - The object to query. * @param {TKey | [TKey]} path - The path of the property to get. * @returns {TObject[TKey]} Returns the resolved value. * * @example * const object = { 'a': [{ 'b': { 'c': 3 } }] }; * get(object, 'a[0].b.c'); * // => 3 */ declare function get(object: TObject, path: TKey | [TKey]): TObject[TKey]; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey * @param {TObject | null | undefined} object - The object to query. * @param {TKey | [TKey]} path - The path of the property to get. * @returns {TObject[TKey] | undefined} Returns the resolved value. * * @example * const object = { 'a': [{ 'b': { 'c': 3 } }] }; * get(object, 'a[0].b.c'); * // => 3 */ declare function get(object: TObject | null | undefined, path: TKey | [TKey]): TObject[TKey] | undefined; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey * @template TDefault * @param {TObject | null | undefined} object - The object to query. * @param {TKey | [TKey]} path - The path of the property to get. * @param {TDefault} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude | TDefault} Returns the resolved value. * * @example * const object = { 'a': [{ 'b': { 'c': 3 } }] }; * get(object, 'a[0].b.c', 'default'); * // => 3 */ declare function get(object: TObject | null | undefined, path: TKey | [TKey], defaultValue: TDefault): Exclude | TDefault; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey1 * @template TKey2 * @param {TObject} object - The object to query. * @param {[TKey1, TKey2]} path - The path of the property to get. * @returns {TObject[TKey1][TKey2]} Returns the resolved value. * * @example * const object = { 'a': { 'b': 2 } }; * get(object, ['a', 'b']); * // => 2 */ declare function get(object: TObject, path: [TKey1, TKey2]): TObject[TKey1][TKey2]; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey1 * @template TKey2 * @param {TObject | null | undefined} object - The object to query. * @param {[TKey1, TKey2]} path - The path of the property to get. * @returns {NonNullable[TKey2] | undefined} Returns the resolved value. * * @example * const object = { 'a': { 'b': 2 } }; * get(object, ['a', 'b']); * // => 2 */ declare function get>(object: TObject | null | undefined, path: [TKey1, TKey2]): NonNullable[TKey2] | undefined; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey1 * @template TKey2 * @template TDefault * @param {TObject | null | undefined} object - The object to query. * @param {[TKey1, TKey2]} path - The path of the property to get. * @param {TDefault} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude[TKey2], undefined> | TDefault} Returns the resolved value. * * @example * const object = { 'a': { 'b': 2 } }; * get(object, ['a', 'b'], 'default'); * // => 2 */ declare function get, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2], defaultValue: TDefault): Exclude[TKey2], undefined> | TDefault; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey1 * @template TKey2 * @template TKey3 * @param {TObject} object - The object to query. * @param {[TKey1, TKey2, TKey3]} path - The path of the property to get. * @returns {TObject[TKey1][TKey2][TKey3]} Returns the resolved value. * * @example * const object = { 'a': { 'b': { 'c': 3 } } }; * get(object, ['a', 'b', 'c']); * // => 3 */ declare function get(object: TObject, path: [TKey1, TKey2, TKey3]): TObject[TKey1][TKey2][TKey3]; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey1 * @template TKey2 * @template TKey3 * @param {TObject | null | undefined} object - The object to query. * @param {[TKey1, TKey2, TKey3]} path - The path of the property to get. * @returns {NonNullable[TKey2]>[TKey3] | undefined} Returns the resolved value. * * @example * const object = { 'a': { 'b': { 'c': 3 } } }; * get(object, ['a', 'b', 'c']); * // => 3 */ declare function get, TKey3 extends keyof NonNullable[TKey2]>>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3]): NonNullable[TKey2]>[TKey3] | undefined; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey1 * @template TKey2 * @template TKey3 * @template TDefault * @param {TObject | null | undefined} object - The object to query. * @param {[TKey1, TKey2, TKey3]} path - The path of the property to get. * @param {TDefault} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude[TKey2]>[TKey3], undefined> | TDefault} Returns the resolved value. * * @example * const object = { 'a': { 'b': { 'c': 3 } } }; * get(object, ['a', 'b', 'c'], 'default'); * // => 3 */ declare function get, TKey3 extends keyof NonNullable[TKey2]>, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3], defaultValue: TDefault): Exclude[TKey2]>[TKey3], undefined> | TDefault; /** * Gets the value at path of object. * * @template TObject * @template TKey1 * @template TKey2 * @template TKey3 * @template TKey4 * @param {TObject} object - The object to query. * @param {[TKey1, TKey2, TKey3, TKey4]} path - The path of the property to get. * @returns {TObject[TKey1][TKey2][TKey3][TKey4]} Returns the resolved value. * * @example * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; * get(object, ['a', 'b', 'c', 'd']); * // => 4 */ declare function get(object: TObject, path: [TKey1, TKey2, TKey3, TKey4]): TObject[TKey1][TKey2][TKey3][TKey4]; /** * Gets the value at path of object. If the resolved value is undefined, undefined is returned. * * @template TObject * @template TKey1 * @template TKey2 * @template TKey3 * @template TKey4 * @param {TObject | null | undefined} object - The object to query. * @param {[TKey1, TKey2, TKey3, TKey4]} path - The path of the property to get. * @returns {NonNullable[TKey2]>[TKey3]>[TKey4] | undefined} Returns the resolved value. * * @example * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; * get(object, ['a', 'b', 'c', 'd']); * // => 4 */ declare function get, TKey3 extends keyof NonNullable[TKey2]>, TKey4 extends keyof NonNullable[TKey2]>[TKey3]>>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3, TKey4]): NonNullable[TKey2]>[TKey3]>[TKey4] | undefined; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TObject * @template TKey1 * @template TKey2 * @template TKey3 * @template TKey4 * @template TDefault * @param {TObject | null | undefined} object - The object to query. * @param {[TKey1, TKey2, TKey3, TKey4]} path - The path of the property to get. * @param {TDefault} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude[TKey2]>[TKey3]>[TKey4], undefined> | TDefault} Returns the resolved value. * * @example * const object = { 'a': { 'b': { 'c': { 'd': 4 } } } }; * get(object, ['a', 'b', 'c', 'd'], 'default'); * // => 4 */ declare function get, TKey3 extends keyof NonNullable[TKey2]>, TKey4 extends keyof NonNullable[TKey2]>[TKey3]>, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3, TKey4], defaultValue: TDefault): Exclude[TKey2]>[TKey3]>[TKey4], undefined> | TDefault; /** * Gets the value at path of object. * * @template T * @param {Record} object - The object to query. * @param {number} path - The path of the property to get. * @returns {T} Returns the resolved value. * * @example * const object = { 0: 'a', 1: 'b', 2: 'c' }; * get(object, 1); * // => 'b' */ declare function get(object: Record, path: number): T; /** * Gets the value at path of object. If the resolved value is undefined, undefined is returned. * * @template T * @param {Record | null | undefined} object - The object to query. * @param {number} path - The path of the property to get. * @returns {T | undefined} Returns the resolved value. * * @example * const object = { 0: 'a', 1: 'b', 2: 'c' }; * get(object, 1); * // => 'b' */ declare function get(object: Record | null | undefined, path: number): T | undefined; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template T * @template TDefault * @param {Record | null | undefined} object - The object to query. * @param {number} path - The path of the property to get. * @param {TDefault} defaultValue - The value returned if the resolved value is undefined. * @returns {T | TDefault} Returns the resolved value. * * @example * const object = { 0: 'a', 1: 'b', 2: 'c' }; * get(object, 1, 'default'); * // => 'b' */ declare function get(object: Record | null | undefined, path: number, defaultValue: TDefault): T | TDefault; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place. * * @template TDefault * @param {null | undefined} object - The object to query. * @param {PropertyPath} path - The path of the property to get. * @param {TDefault} defaultValue - The value returned if the resolved value is undefined. * @returns {TDefault} Returns the default value. * * @example * get(null, 'a.b.c', 'default'); * // => 'default' */ declare function get(object: null | undefined, path: PropertyPath, defaultValue: TDefault): TDefault; /** * Gets the value at path of object. If the resolved value is undefined, undefined is returned. * * @param {null | undefined} object - The object to query. * @param {PropertyPath} path - The path of the property to get. * @returns {undefined} Returns undefined. * * @example * get(null, 'a.b.c'); * // => undefined */ declare function get(object: null | undefined, path: PropertyPath): undefined; /** * Gets the value at path of object using type-safe path. * * @template TObject * @template TPath * @param {TObject} data - The object to query. * @param {TPath} path - The path of the property to get. * @returns {string extends TPath ? any : GetFieldType} Returns the resolved value. * * @example * const object = { a: { b: { c: 1 } } }; * get(object, 'a.b.c'); * // => 1 */ declare function get(data: TObject, path: TPath): string extends TPath ? any : GetFieldType; /** * Gets the value at path of object using type-safe path. If the resolved value is undefined, the defaultValue is returned. * * @template TObject * @template TPath * @template TDefault * @param {TObject} data - The object to query. * @param {TPath} path - The path of the property to get. * @param {TDefault} defaultValue - The value returned if the resolved value is undefined. * @returns {Exclude, null | undefined> | TDefault} Returns the resolved value. * * @example * const object = { a: { b: { c: 1 } } }; * get(object, 'a.b.d', 'default'); * // => 'default' */ declare function get>(data: TObject, path: TPath, defaultValue: TDefault): Exclude, null | undefined> | TDefault; /** * Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned. * * @param {any} object - The object to query. * @param {PropertyPath} path - The path of the property to get. * @param {any} [defaultValue] - The value returned if the resolved value is undefined. * @returns {any} Returns the resolved value. * * @example * const object = { a: { b: { c: 1 } } }; * get(object, 'a.b.c', 'default'); * // => 1 */ declare function get(object: any, path: PropertyPath, defaultValue?: any): any; export { get };