Function filter

  • Filters elements from an iterable on a value or a filtering function.

    Type Parameters

    • Iter extends AnyIt<unknown>
    • V extends unknown

    Parameters

    • iter: Iter

      The iterable or async iterable to filter.

    • condition: V | Matcher<V>

      The value or filtering function used for filtering elements.

    Returns AnyItResultIt<Iter, V>

    The filtered iterable.

    Example

    // Returns an Iterable representing [1, 1]
    it.filter([1, 2, 3, 1], x => x < 2)

    Example

    // Returns an Iterable representing [1, 1]
    it.filter([1, 2, 3, 1], 1)
  • This is the curried form of filter.

    Type Parameters

    • Iter extends AnyIt<unknown>
    • V extends unknown

    Parameters

    • condition: V | Matcher<V>

    Returns CurriedAnyItResultIt<Iter, V>