ts-iterable-functions
    Preparing search index...

    Function filter

    • Filters items from a source iterable using a predicate, optionally narrowing the element type.

      Type Parameters

      • T

        Element type produced by the source iterable.

      • S

        Narrowed element type when pred acts as a type guard.

      Parameters

      • pred: TypeGuardPredicate<T, S>

        Predicate invoked with each element and its index to determine inclusion.

      Returns (src: Iterable<T>) => Iterable<S>

      A transformer that yields every element for which pred returns a truthy value.

      Error Rethrows any error thrown by pred.

      const odds = [
      ...pipeInto(
      [1, 2, 3, 4],
      filter((value) => value % 2 === 1)
      ),
      ];
      console.log(odds); // [1, 3]
    • Filters items from a source iterable using a predicate, optionally narrowing the element type.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • pred: IndexedPredicate<T>

        Predicate invoked with each element and its index to determine inclusion.

      Returns (src: Iterable<T>) => Iterable<T>

      A transformer that yields every element for which pred returns a truthy value.

      Error Rethrows any error thrown by pred.

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