Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object/propOr

Index

References

Functions

References

Renames and re-exports propOr

Functions

  • propOr<K, V, O>(prop: K, value: V, obj: O): O[K]
  • propOr<K, V>(prop: K, value: V, obj: any): V
  • propOr<K, V>(prop: K, value: V): { <O>(obj: O): O[K]; (obj: any): V }
  • propOr<K>(prop: K): { <V, O>(value: V, obj: O): O[K]; <V>(value: V): V; <V>(value: V): { <O>(obj: O): O[K]; (obj: any): V } }
  • If the given, non-null object has an own property with the specified name, returns the value of that property. Otherwise returns the provided default value.

    example
     var alice = {
    name: 'ALICE',
    age: 101
    };

    propOr('name', 'Bob')(alice); //=> 'ALICE'
    propOr('favoriteLibrary', 'react')(alice); //=> 'react'

    Type parameters

    • K: string | number | symbol

    • V

    • O: Record<K, any>

    Parameters

    • prop: K
    • value: V

      The default value.

    • obj: O

      The object to query.

    Returns O[K]

    The value of given property of the supplied object or the default value.

  • If the given, non-null object has an own property with the specified name, returns the value of that property. Otherwise returns the provided default value.

    example
     var alice = {
    name: 'ALICE',
    age: 101
    };

    propOr('name', 'Bob')(alice); //=> 'ALICE'
    propOr('favoriteLibrary', 'react')(alice); //=> 'react'

    Type parameters

    • K: string | number | symbol

    • V

    Parameters

    • prop: K
    • value: V

      The default value.

    • obj: any

      The object to query.

    Returns V

    The value of given property of the supplied object or the default value.

  • If the given, non-null object has an own property with the specified name, returns the value of that property. Otherwise returns the provided default value.

    example
     var alice = {
    name: 'ALICE',
    age: 101
    };

    propOr('name', 'Bob')(alice); //=> 'ALICE'
    propOr('favoriteLibrary', 'react')(alice); //=> 'react'

    Type parameters

    • K: string | number | symbol

    • V

    Parameters

    • prop: K
    • value: V

      The default value.

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

    The value of given property 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 an own property with the specified name, returns the value of that property. Otherwise returns the provided default value.

    example
     var alice = {
    name: 'ALICE',
    age: 101
    };

    propOr('name', 'Bob')(alice); //=> 'ALICE'
    propOr('favoriteLibrary', 'react')(alice); //=> 'react'

    Type parameters

    • K: string | number | symbol

    Parameters

    • prop: K

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

    The value of given property of the supplied object or the default value.

      • <V, O>(value: V, obj: O): O[K]
      • <V>(value: V): 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

        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

Generated using TypeDoc