Options
All
  • Public
  • Public/Protected
  • All
Menu

Module matches

Index

References

Functions Util

References

Renames and re-exports matches

Util Functions

  • matches<T>(source: T[]): ((obj: T) => boolean)
  • Creates a function that performs a partial deep comparison between a given object and source, returning true if the given object has equivalent property values, else false.

    Note: The created function is equivalent to isMatch with source partially applied.

    Partial comparisons will match empty array and empty object source values against any array or object value, respectively. See isEqual for a list of supported value comparisons.

    since

    5.11.0

    example

    const objects = [ { 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 } ]

    filter(objects, matches({ 'a': 4, 'c': 6 })) // => [{ 'a': 4, 'b': 5, 'c': 6 }]

    Type Parameters

    • T

    Parameters

    • source: T[]

      The object of property values to match.

    Returns ((obj: T) => boolean)

    Returns the new spec function.

      • (obj: T): boolean
      • Creates a function that performs a partial deep comparison between a given object and source, returning true if the given object has equivalent property values, else false.

        Note: The created function is equivalent to isMatch with source partially applied.

        Partial comparisons will match empty array and empty object source values against any array or object value, respectively. See isEqual for a list of supported value comparisons.

        since

        5.11.0

        category

        Util

        example

        const objects = [ { 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 } ]

        filter(objects, matches({ 'a': 4, 'c': 6 })) // => [{ 'a': 4, 'b': 5, 'c': 6 }]

        Parameters

        • obj: T

        Returns boolean

        Returns the new spec function.