effect-ts-laws
    Preparing search index...

    Function filterLaws

    • Filter the laws that are direct children of a LawSet by matching a regular expression on the law name, and return the new filtered LawSet. LawSets that survive the filter remain untouched.

      Useful when you need to remove from a LawSet laws that are problematic perhaps because they are slow or difficult to generate.

      Parameters

      • re: RegExp

        Regular expression will be matched vs. law name.

      Returns (__namedParameters: LawSet) => LawSet

      Input LawSet, but includes only laws with names matching re.

        • (__namedParameters: LawSet): LawSet
        • LawSet that is parent of laws to be filtered.

          Parameters

          Returns LawSet

      import {equivalenceLaws, filterLaws, tinyInteger} from 'effect-ts-laws'
      import {Number as NU, pipe} from 'effect'

      // Extract reflexivity law from equivalence laws.
      const reflexivity = pipe(
      {a: tinyInteger, equalsA: NU.Equivalence, F: NU.Equivalence},
      equivalenceLaws<number>,
      filterLaws(/reflexivity/),
      )

      assert.equal(reflexivity.laws.length, 1)
      assert.equal(reflexivity.laws[0]?.name, 'reflexivity')