cartesian.ts — tailwindcss Source File
Architecture documentation for cartesian.ts, a typescript file in the tailwindcss codebase. 0 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 4d385060_88c8_95d1_bd14_4eb53b36b689["cartesian.ts"] a57d0003_9aa7_26da_25b8_b100327975d6["canonicalize-candidates.test.ts"] a57d0003_9aa7_26da_25b8_b100327975d6 --> 4d385060_88c8_95d1_bd14_4eb53b36b689 style 4d385060_88c8_95d1_bd14_4eb53b36b689 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
type CartesianInput = readonly unknown[][]
type CartesianResult<T extends CartesianInput> = T extends [
infer Head extends unknown[],
...infer Tail extends CartesianInput,
]
? [Head[number], ...CartesianResult<Tail>]
: []
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
Functions
Source
Frequently Asked Questions
What does cartesian.ts do?
cartesian.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the Oxide domain, Scanner subdomain.
What functions are defined in cartesian.ts?
cartesian.ts defines 1 function(s): cartesian.
What files import cartesian.ts?
cartesian.ts is imported by 1 file(s): canonicalize-candidates.test.ts.
Where is cartesian.ts in the architecture?
cartesian.ts is located at packages/tailwindcss/src/cartesian.ts (domain: Oxide, subdomain: Scanner, directory: packages/tailwindcss/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free