Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object/any

Index

References

Functions

References

Renames and re-exports any

Functions

  • any<K, V>(fn: ObjPred<K, V>, obj: Record<K, V>): boolean
  • any<K, V>(fn: ObjPred<K, V>): (obj: Record<K, V>) => boolean
  • Tests whether at least one [key, value] pair in the object passes the test implemented by the provided function.

    example
     var isBiggerThanZero = x => x > 0;

    any(isBiggerThanZero, {}); //=> false
    any(isBiggerThanZero, { a: 0 }); //=> false
    any(isBiggerThanZero, { a: 0, b: 1, c: 0 }); //=> true
    any(isBiggerThanZero, { a: 1, b: 0, c: -1 }); //=> true
    any(isBiggerThanZero)({ a: 0, b: 0, c: 0 }); //=> false
    any(isBiggerThanZero)({ a: 0, b: 1, c: 0 }); //=> true

    Type parameters

    • K: string

    • V

    Parameters

    • fn: ObjPred<K, V>

      The function to test for each [key, value] pair. Takes a predicate and an object.

    • obj: Record<K, V>

      The object whose enumerable own property [key, value] pairs are to be tested.

    Returns boolean

    Returns true if the callback function returns a truthy value for any [key, value] pair, otherwise, false.

  • Tests whether at least one [key, value] pair in the object passes the test implemented by the provided function.

    example
     var isBiggerThanZero = x => x > 0;

    any(isBiggerThanZero, {}); //=> false
    any(isBiggerThanZero, { a: 0 }); //=> false
    any(isBiggerThanZero, { a: 0, b: 1, c: 0 }); //=> true
    any(isBiggerThanZero, { a: 1, b: 0, c: -1 }); //=> true
    any(isBiggerThanZero)({ a: 0, b: 0, c: 0 }); //=> false
    any(isBiggerThanZero)({ a: 0, b: 1, c: 0 }); //=> true

    Type parameters

    • K: string

    • V

    Parameters

    • fn: ObjPred<K, V>

      The function to test for each [key, value] pair. Takes a predicate and an object.

    Returns (obj: Record<K, V>) => boolean

    Returns true if the callback function returns a truthy value for any [key, value] pair, otherwise, false.

      • (obj: Record<K, V>): boolean
      • Parameters

        • obj: Record<K, V>

        Returns boolean

Generated using TypeDoc