• Provides a way to safely access an objects data / entries given an accessor string which describes the entries to walk. To access deeper entries into the object format the accessor string with . between entries to walk.

    Type Parameters

    • T extends object

      Type of data.

    • P extends string

      Accessor type.

    • R = DeepAccess<T, P>

      Return value / Inferred deep access type or any provided default value type.

    Parameters

    • data: T

      An object to access entry data.

    • accessor: P

      A string describing the entries to access with keys separated by ..

    • OptionaldefaultValue: DeepAccess<T, P> extends undefined ? R : DeepAccess<T, P>

      (Optional) A default value to return if an entry for accessor is not found.

    Returns DeepAccess<T, P> extends undefined ? R : DeepAccess<T, P>

    The value referenced by the accessor.