everyutil
Version:
A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.
22 lines (21 loc) • 498 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cross = void 0;
/**
* Returns the Cartesian product of two arrays.
* @author @dailker
* @template A, B
* @param {A[]} arrayA
* @param {B[]} arrayB
* @returns {[A, B][]}
*/
function cross(arrayA, arrayB) {
const result = [];
for (const a of arrayA) {
for (const b of arrayB) {
result.push([a, b]);
}
}
return result;
}
exports.cross = cross;