Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object/pathOr

Index

References

Functions

References

Renames and re-exports pathOr

Functions

  • pathOr<K, V, O>(path: [K], value: V, obj: O): O[K]
  • pathOr<K, V>(path: [K], value: V, obj: any): V
  • pathOr<K, V>(path: [K], value: V): { <O>(obj: O): O[K]; (obj: any): V }
  • pathOr<K>(path: [K]): { <V, O>(value: V, obj: O): O[K]; <V>(value: V, obj: any): V; <V>(value: V): { <O>(obj: O): O[K]; (obj: any): V } }
  • pathOr(path: Paths, value: any, obj: any): any
  • pathOr(path: Paths, value: any): (obj: any) => any
  • pathOr(path: Paths): CurriedFunction2<any, any, any>
  • If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

    example
     pathOr(['a', 'b'],'N/A', {a: {b: 2}}); //=> 2
    pathOr(['a', 'b'], 'N/A', {c: {b: 2}}); //=> "N/A"

    Type parameters

    • K: string | number | symbol

    • V

    • O: Record<K, any>

    Parameters

    • path: [K]
    • value: V

      The default value.

    • obj: O

      The object to retrieve the nested property from.

    Returns O[K]

    The data at path of the supplied object or the default value.

  • If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

    example
     pathOr(['a', 'b'],'N/A', {a: {b: 2}}); //=> 2
    pathOr(['a', 'b'], 'N/A', {c: {b: 2}}); //=> "N/A"

    Type parameters

    • K: string | number | symbol

    • V

    Parameters

    • path: [K]
    • value: V

      The default value.

    • obj: any

      The object to retrieve the nested property from.

    Returns V

    The data at path of the supplied object or the default value.

  • If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

    example
     pathOr(['a', 'b'],'N/A', {a: {b: 2}}); //=> 2
    pathOr(['a', 'b'], 'N/A', {c: {b: 2}}); //=> "N/A"

    Type parameters

    • K: string | number | symbol

    • V

    Parameters

    • path: [K]
    • value: V

      The default value.

    Returns { <O>(obj: O): O[K]; (obj: any): V }

    The data at path of the supplied object or the default value.

      • <O>(obj: O): O[K]
      • (obj: any): V
      • Type parameters

        • O: Record<K, any>

        Parameters

        • obj: O

        Returns O[K]

      • Parameters

        • obj: any

        Returns V

  • If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

    example
     pathOr(['a', 'b'],'N/A', {a: {b: 2}}); //=> 2
    pathOr(['a', 'b'], 'N/A', {c: {b: 2}}); //=> "N/A"

    Type parameters

    • K: string | number | symbol

    Parameters

    • path: [K]

    Returns { <V, O>(value: V, obj: O): O[K]; <V>(value: V, obj: any): V; <V>(value: V): { <O>(obj: O): O[K]; (obj: any): V } }

    The data at path of the supplied object or the default value.

      • <V, O>(value: V, obj: O): O[K]
      • <V>(value: V, obj: any): V
      • <V>(value: V): { <O>(obj: O): O[K]; (obj: any): V }
      • Type parameters

        • V

        • O: Record<K, any>

        Parameters

        • value: V
        • obj: O

        Returns O[K]

      • Type parameters

        • V

        Parameters

        • value: V
        • obj: any

        Returns V

      • Type parameters

        • V

        Parameters

        • value: V

        Returns { <O>(obj: O): O[K]; (obj: any): V }

          • <O>(obj: O): O[K]
          • (obj: any): V
          • Type parameters

            • O: Record<K, any>

            Parameters

            • obj: O

            Returns O[K]

          • Parameters

            • obj: any

            Returns V

  • If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

    example
     pathOr(['a', 'b'],'N/A', {a: {b: 2}}); //=> 2
    pathOr(['a', 'b'], 'N/A', {c: {b: 2}}); //=> "N/A"

    Parameters

    • path: Paths
    • value: any

      The default value.

    • obj: any

      The object to retrieve the nested property from.

    Returns any

    The data at path of the supplied object or the default value.

  • If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

    example
     pathOr(['a', 'b'],'N/A', {a: {b: 2}}); //=> 2
    pathOr(['a', 'b'], 'N/A', {c: {b: 2}}); //=> "N/A"

    Parameters

    • path: Paths
    • value: any

      The default value.

    Returns (obj: any) => any

    The data at path of the supplied object or the default value.

      • (obj: any): any
      • Parameters

        • obj: any

        Returns any

  • If the given, non-null object has a value at the given path, returns the value at that path. Otherwise returns the provided default value.

    example
     pathOr(['a', 'b'],'N/A', {a: {b: 2}}); //=> 2
    pathOr(['a', 'b'], 'N/A', {c: {b: 2}}); //=> "N/A"

    Parameters

    Returns CurriedFunction2<any, any, any>

    The data at path of the supplied object or the default value.

Generated using TypeDoc