ts-iterable-functions
    Preparing search index...

    Function _groupJoin

    • Performs a group join pairing each outer element with the group of matching inner elements.

      Type Parameters

      • T

        Element type produced by the outer source iterable.

      • TInner

        Element type produced by the inner source iterable.

      • TKey

        Key type generated by the key selector functions.

      • TOut

        Result type emitted by the selector.

      Parameters

      • src: Iterable<T>

        Outer source iterable enumerated sequentially.

      • innerSeq: Iterable<TInner>

        Inner source iterable used to build a lookup for matching keys.

      • outerKeySelector: IndexedSelector<T, TKey>

        Selector producing a key for each outer element.

      • innerKeySelector: IndexedSelector<TInner, TKey>

        Selector producing a key for each inner element.

      • selector: (o: T, v: Iterable<TInner>) => TOut

        Projection receiving the current outer element and the iterable of matching inner elements.

      • OptionalmapFactory: MapFactory<TKey>

        Optional factory used to create the internal map for lookups.

      Returns Iterable<TOut>

      A deferred iterable yielding the result of selector for every element in the outer sequence.

      const result = [..._groupJoin(
      [
      { id: 1, name: "Alice" },
      { id: 2, name: "Bob" }
      ],
      [
      { userId: 1, order: "A" },
      { userId: 1, order: "B" },
      { userId: 3, order: "C" }
      ],
      (user) => user.id,
      (order) => order.userId,
      (user, orders) => ({
      name: user.name,
      orders: [...orders].map((order) => order.order)
      })
      )];
      console.log(result);
      // [
      // { name: "Alice", orders: ["A", "B"] },
      // { name: "Bob", orders: [] }
      // ]

      or using the curried version:

      const result = pipeInto(
      [
      { id: 1, name: "Taylor" }
      ],
      groupJoin(
      [
      { userId: 1, order: "Order-1" },
      { userId: 2, order: "Order-2" }
      ],
      (user) => user.id,
      (order) => order.userId,
      (user, orders) => ({
      name: user.name,
      orders: [...orders].map((order) => order.order)
      })
      )
      );
      console.log([...result]);
      // [
      // { name: "Taylor", orders: ["Order-1"] }
      // ]