Options
All
  • Public
  • Public/Protected
  • All
Menu

Module conforms

Index

References

Functions Util

References

Renames and re-exports conforms

Util Functions

  • conforms<T>(source: { [ key in string | number | symbol]?: ((value: any) => boolean) }): ((obj: T) => boolean)
  • conforms(source: any): any
  • Creates a function that invokes the predicate properties of source with the corresponding property values of a given object, returning true if all predicates return truthy, else false.

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

    since

    5.12.0

    example
    const objects = [
    { 'a': 2, 'b': 1 },
    { 'a': 1, 'b': 2 }
    ]

    filter(objects, conforms({ 'b': function(n) { return n > 1 } }))
    // => [{ 'a': 1, 'b': 2 }]

    Type Parameters

    • T extends Record<string, any>

    Parameters

    • source: { [ key in string | number | symbol]?: ((value: any) => boolean) }

      The object of property predicates to conform to.

    Returns ((obj: T) => boolean)

    Returns the new spec function.

      • (obj: T): boolean
      • Creates a function that invokes the predicate properties of source with the corresponding property values of a given object, returning true if all predicates return truthy, else false.

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

        since

        5.12.0

        category

        Util

        example
        const objects = [
        { 'a': 2, 'b': 1 },
        { 'a': 1, 'b': 2 }
        ]

        filter(objects, conforms({ 'b': function(n) { return n > 1 } }))
        // => [{ 'a': 1, 'b': 2 }]

        Parameters

        • obj: T

        Returns boolean

        Returns the new spec function.

  • Parameters

    • source: any

    Returns any