Files
bun.sh/test/_util/collection.ts
Marko Vejnovic 02b474415d bug(ENG-21479): Fix Valkey URL Parsing (#24458)
### What does this PR do?

Fixes https://github.com/oven-sh/bun/issues/24385

### How did you verify your code works?

Confirmed that the test added in the first commit fails on mainline
`bun` and is fixed in this PR.

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-11-07 21:18:07 -08:00

12 lines
404 B
TypeScript

/**
* Computes the Cartesian product of multiple arrays.
*
* @param arrays An array of arrays for which to compute the Cartesian product.
* @returns An array containing all combinations of elements from the input arrays.
*/
export function cartesianProduct<T, U>(left: T[], right: U[]): [T, U][] {
return left.flatMap(leftItem =>
right.map(rightItem => [leftItem, rightItem] as [T, U])
);
}