Function get

  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K extends string | number | symbol

      The type of the key in the object.

    Parameters

    • object: T

      The object to query.

    • path: K | readonly [K]

      The path of the property to get.

    Returns T[K]

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K extends string | number | symbol

      The type of the key in the object.

    Parameters

    • object: undefined | null | T

      The object to query.

    • path: K | readonly [K]

      The path of the property to get.

    Returns T[K] | undefined

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K extends string | number | symbol

      The type of the key in the object.

    • D

      The type of the default value.

    Parameters

    • object: undefined | null | T

      The object to query.

    • path: K | readonly [K]

      The path of the property to get.

    • defaultValue: D

      The value returned if the resolved value is undefined.

    Returns Exclude<T[K], undefined> | D

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    Parameters

    • object: T

      The object to query.

    • path: readonly [K1, K2]

      The path of the property to get.

    Returns T[K1][K2]

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    Parameters

    • object: undefined | null | T

      The object to query.

    • path: readonly [K1, K2]

      The path of the property to get.

    Returns T[K1][K2] | undefined

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    • D

      The type of the default value.

    Parameters

    • object: undefined | null | T

      The object to query.

    • path: readonly [K1, K2]

      The path of the property to get.

    • defaultValue: D

      The value returned if the resolved value is undefined.

    Returns Exclude<T[K1][K2], undefined> | D

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    • K3 extends string | number | symbol

      The type of the third key in the object.

    Parameters

    • object: T

      The object to query.

    • path: readonly [K1, K2, K3]

      The path of the property to get.

    Returns T[K1][K2][K3]

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    • K3 extends string | number | symbol

      The type of the third key in the object.

    Parameters

    • object: undefined | null | T

      The object to query.

    • path: readonly [K1, K2, K3]

      The path of the property to get.

    Returns T[K1][K2][K3] | undefined

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    • K3 extends string | number | symbol

      The type of the third key in the object.

    • D

      The type of the default value.

    Parameters

    • object: undefined | null | T

      The object to query.

    • path: readonly [K1, K2, K3]

      The path of the property to get.

    • defaultValue: D

      The value returned if the resolved value is undefined.

    Returns Exclude<T[K1][K2][K3], undefined> | D

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    • K3 extends string | number | symbol

      The type of the third key in the object.

    • K4 extends string | number | symbol

      The type of the fourth key in the object.

    Parameters

    • object: T

      The object to query.

    • path: readonly [K1, K2, K3, K4]

      The path of the property to get.

    Returns T[K1][K2][K3][K4]

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    • K3 extends string | number | symbol

      The type of the third key in the object.

    • K4 extends string | number | symbol

      The type of the fourth key in the object.

    Parameters

    • object: undefined | null | T

      The object to query.

    • path: readonly [K1, K2, K3, K4]

      The path of the property to get.

    Returns T[K1][K2][K3][K4] | undefined

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T extends object

      The type of the object.

    • K1 extends string | number | symbol

      The type of the first key in the object.

    • K2 extends string | number | symbol

      The type of the second key in the object.

    • K3 extends string | number | symbol

      The type of the third key in the object.

    • K4 extends string | number | symbol

      The type of the fourth key in the object.

    • D

      The type of the default value.

    Parameters

    • object: undefined | null | T

      The object to query.

    • path: readonly [K1, K2, K3, K4]

      The path of the property to get.

    • defaultValue: D

      The value returned if the resolved value is undefined.

    Returns Exclude<T[K1][K2][K3][K4], undefined> | D

    • Returns the resolved value.
  • Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T

      The type of the value.

    Parameters

    • object: Record<number, T>

      The object to query.

    • path: number

      The path of the property to get.

    Returns T

    • Returns the resolved value.
  • Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T

      The type of the value.

    Parameters

    • object: undefined | null | Record<number, T>

      The object to query.

    • path: number

      The path of the property to get.

    Returns T | undefined

    • Returns the resolved value.
  • Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T

      The type of the value.

    • D

      The type of the default value.

    Parameters

    • object: undefined | null | Record<number, T>

      The object to query.

    • path: number

      The path of the property to get.

    • defaultValue: D

      The value returned if the resolved value is undefined.

    Returns T | D

    • Returns the resolved value.
  • Retrieves the value at a given path from a null or undefined object, returning the default value.

    Type Parameters

    • D

      The type of the default value.

    Parameters

    • object: undefined | null

      The object to query.

    • path: PropertyKey

      The path of the property to get.

    • defaultValue: D

      The value returned if the resolved value is undefined.

    Returns D

    • Returns the default value.
  • Retrieves the value at a given path from a null or undefined object, returning undefined.

    Parameters

    • object: undefined | null

      The object to query.

    • path: PropertyKey

      The path of the property to get.

    Returns undefined

    • Returns undefined.
  • Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T

      The type of the object.

    • P extends string

      The type of the path.

    Parameters

    • data: T

      The object to query.

    • path: P

      The path of the property to get.

    Returns string extends P
        ? any
        : Get<T, P>

    • Returns the resolved value.
  • Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.

    Type Parameters

    • T

      The type of the object.

    • P extends string

      The type of the path.

    • D = Get<T, P>

      The type of the default value.

    Parameters

    • data: T

      The object to query.

    • path: P

      The path of the property to get.

    • defaultValue: D

      The value returned if the resolved value is undefined.

    Returns Exclude<Get<T, P>, null | undefined> | D

    • Returns the resolved value.
  • Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.

    Parameters

    • object: unknown

      The object to query.

    • path: PropertyKey | readonly PropertyKey[]

      The path of the property to get.

    • OptionaldefaultValue: unknown

      The value returned if the resolved value is undefined.

    Returns any

    • Returns the resolved value.