• 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

    Type Parameters

    • Item

    Parameters

    • predicate: Filter<Item>

      Predicate function for items to be counted.

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

    Curried function with predicate in context.