Function count

  • Counts the number of items that satisfy a predicate in the given iterable or asynchronous iterable.

    Example

    const countOdds = count((number: number) => number % 2 !== 1);
    countOdds([1, 2, 3, 4, 5]); // 3
    countOdds([0, 2, 4, 6, 8]); // 0

    Returns

    Curried function with predicate in context.

    Type Parameters

    • Item

    • Predicated

    Parameters

    • predicate: Predicate<Item, Predicated>

      Predicate function for items to be counted.

    Returns (<Iterable>(iterable: Iterable) => ReducerOutput<GeneratorOutput<Iterable>, number>)