Function product

  • Returns a Stream that merges elements from both iterables by taking one element from each, passing them to the function, and yielding the result.

    Type Parameters

    • A
    • B
    • O

    Parameters

    • a: Iterable<A>

      The first iterable to merge.

    • b: Iterable<B>

      The second iterable to merge.

    • productFunction: ((a: A, b: B) => O)

      The function that merges the elements.

        • (a, b): O
        • Parameters

          Returns O

    Returns Stream<O>

    A Stream that merges elements from both iterables.

    const result = product('ABCD', 'xy', (a, b) => `${a}${b}`);
    console.log([...result]); // ['Ax', 'Ay', 'Bx', 'By', 'Cx', 'Cy', 'Dx', 'Dy']