combinations() — tailwindcss Function Reference
Architecture documentation for the combinations() function in canonicalize-candidates.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 1afe933f_54d9_6585_5a06_51a83e5a53c8["combinations()"] 71b68838_221b_7f75_2376_3e23d6c37929["collapseCandidates()"] 71b68838_221b_7f75_2376_3e23d6c37929 -->|calls| 1afe933f_54d9_6585_5a06_51a83e5a53c8 style 1afe933f_54d9_6585_5a06_51a83e5a53c8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/canonicalize-candidates.ts lines 2574–2600
function* combinations<T>(arr: T[]): Generator<T[]> {
let n = arr.length
let limit = 1n << BigInt(n)
for (let k = n; k >= 2; k--) {
let mask = (1n << BigInt(k)) - 1n
while (mask < limit) {
let out = []
for (let i = 0; i < n; i++) {
if ((mask >> BigInt(i)) & 1n) {
out.push(arr[i])
}
}
yield out
// Gosper's hack:
// - https://programmingforinsomniacs.blogspot.com/2018/03/gospers-hack-explained.html
// - https://rosettacode.org/wiki/Gosper%27s_hack
//
// We need to generate the next mask in lexicographical order.
let carry = mask & -mask
let ripple = mask + carry
mask = (((ripple ^ mask) >> 2n) / carry) | ripple
}
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does combinations() do?
combinations() is a function in the tailwindcss codebase.
What calls combinations()?
combinations() is called by 1 function(s): collapseCandidates.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free