ts-iterable-functions
    Preparing search index...

    Function countConst

    • Counts the elements of the source iterable that satisfy the optional predicate.

      Curried version of _count.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • pred: IndexedPredicate<T> = ...

        Predicate receiving each element and its index; truthy results increment the count.

      Returns (src: Iterable) => number

      Number of elements accepted by pred, or the total element count when omitted.

      Error Rethrows any error thrown by pred.

      const evens = _count([1, 2, 3, 4], (value) => value % 2 === 0);
      console.log(evens); // 2

      or using the curried version:

      const evens = pipeInto([1, 2, 3, 4], count((value) => value % 2 === 0));
      console.log(evens); // 2