ts-iterable-functions
    Preparing search index...

    Function _intersect

    • Yields the elements that appear in both the source iterable and the comparison sequence.

      Type Parameters

      • T

        Element type produced by the source iterable and comparison sequence.

      Parameters

      • src: Iterable<T>

        Source iterable enumerated for intersecting values.

      • seq: Iterable<T>

        Iterable providing the values to retain from src.

      • setFactory: SetFactory<T> = ...

        Optional factory supplying the set used to test membership.

      Returns Iterable<T>

      A deferred iterable yielding items found in both sequences, preserving source order.

      Error Rethrows any error thrown by setFactory.

      const result = [..._intersect([1, 2, 3, 4], [2, 4, 6])];
      console.log(result); // [2, 4]

      or using the curried version:

      const result = [
      ...pipeInto(
      [1, 2, 3, 4],
      intersect([2, 4, 6])
      ),
      ];
      console.log(result); // [2, 4]