effect-tree - v1.0.36
    Preparing search index...

    Function countOf

    • Compute how many nodes in a tree satisfy the given predicate.

      Type Parameters

      • A

      Parameters

      • predicate: Predicate<A>

      Returns TreeFold<A, number>

      import {tree, from, of, countOf} from 'effect-tree'
      import {pipe} from 'effect'

      const actual = pipe(
      [of(2), from(3, of(4), of(5)), of(6)],
      tree.flipped(1),
      countOf(n => n % 2 === 0),
      )

      expect(actual).toBe(3)