• Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.

    Differences from lodash:

    • does not handle a dot-separated string for path

    Contribution to minified bundle size, when it is the only function imported:

    • Lodash: 6,051 bytes
    • Micro-dash: 237 bytes

    Type Parameters

    • T
    • K extends string | number | symbol
    • D = undefined

    Parameters

    • object: T
    • key: K
    • Optional defaultValue: D

    Returns IfCouldBe<T, Nil, D> | WithDefault<NonNullable<T>[K], D>

  • Type Parameters

    • D = undefined

    Parameters

    • object: object
    • path: []
    • Optional defaultValue: D

    Returns D

  • Type Parameters

    • T
    • K1 extends string | number | symbol
    • D = undefined

    Parameters

    • object: T
    • path: readonly [K1]
    • Optional defaultValue: D

    Returns IfCouldBe<T, Nil, D> | WithDefault<NonNullable<T>[K1], D>

  • Type Parameters

    • T
    • K1 extends string | number | symbol
    • K2 extends string | number | symbol
    • D = undefined

    Parameters

    • object: T
    • path: readonly [K1, K2]
    • Optional defaultValue: D

    Returns IfCouldBe<T, Nil, D> | WithDefault<NonNullable<T>[K1][K2], D>

  • Type Parameters

    • T
    • K1 extends string | number | symbol
    • K2 extends string | number | symbol
    • K3 extends string | number | symbol
    • D = undefined

    Parameters

    • object: T
    • path: readonly [K1, K2, K3]
    • Optional defaultValue: D

    Returns IfCouldBe<T, Nil, D> | WithDefault<NonNullable<T>[K1][K2][K3], D>

  • Type Parameters

    • T
    • K1 extends string | number | symbol
    • K2 extends string | number | symbol
    • K3 extends string | number | symbol
    • K4 extends string | number | symbol
    • D = undefined

    Parameters

    • object: T
    • path: readonly [K1, K2, K3, K4]
    • Optional defaultValue: D

    Returns IfCouldBe<T, Nil, D> | WithDefault<NonNullable<T>[K1][K2][K3][K4], D>

  • Parameters

    • object: object | Nil
    • path: readonly PropertyKey[]
    • Optional defaultValue: any

    Returns any