cartesian() — tailwindcss Function Reference
Architecture documentation for the cartesian() function in cartesian.ts from the tailwindcss codebase.
Entity Profile
Relationship Graph
Source Code
packages/tailwindcss/src/cartesian.ts lines 10–45
export function* cartesian<T extends CartesianInput>(...sets: T): Generator<CartesianResult<T>> {
let n = sets.length
if (n === 0) return
// If any input set is empty, the Cartesian product is empty.
if (sets.some((set) => set.length === 0)) {
return
}
// Index lookup
let idx = Array(n).fill(0)
while (true) {
// Compute current combination
let result = [] as CartesianResult<T>
for (let i = 0; i < n; i++) {
result[i] = sets[i][idx[i]]
}
yield result
// Update index vector
let k = n - 1
while (k >= 0) {
idx[k]++
if (idx[k] < sets[k].length) {
break
}
idx[k] = 0
k--
}
if (k < 0) {
return
}
}
}
Domain
Subdomains
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free