Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object/where

Index

References

Functions

References

Renames and re-exports where

Functions

  • where<O>(spec: Partial<Record<keyof O, ObjPredBy<O>>>, obj: O): boolean
  • where(spec: Record<string | number | symbol, ObjPred<string, any>>): (obj: any) => boolean
  • Takes a spec object and a test object; returns true if the test satisfies the spec. Each of the spec's own properties must be a predicate function. Each predicate is applied to the value of the corresponding property of the test object. where returns true if all the predicates return true, false otherwise.

    example
     // pred :: Object -> Boolean
    var pred = where({
    a: isEqual('foo'),
    b: complement(isEqual('bar')),
    x: a => a > 10,
    y: a => a < 20
    });

    pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true
    pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false
    pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false
    pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false
    pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false

    Type parameters

    • O

    Parameters

    • spec: Partial<Record<keyof O, ObjPredBy<O>>>
    • obj: O

    Returns boolean

  • Takes a spec object and a test object; returns true if the test satisfies the spec. Each of the spec's own properties must be a predicate function. Each predicate is applied to the value of the corresponding property of the test object. where returns true if all the predicates return true, false otherwise.

    example
     // pred :: Object -> Boolean
    var pred = where({
    a: isEqual('foo'),
    b: complement(isEqual('bar')),
    x: a => a > 10,
    y: a => a < 20
    });

    pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true
    pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false
    pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false
    pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false
    pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false

    Parameters

    • spec: Record<string | number | symbol, ObjPred<string, any>>

    Returns (obj: any) => boolean

      • (obj: any): boolean
      • Parameters

        • obj: any

        Returns boolean

Generated using TypeDoc