printArbitraryValueCache() — tailwindcss Function Reference
Architecture documentation for the printArbitraryValueCache() function in candidate.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 258ace88_f7c6_412f_9b37_95e1bd249268["printArbitraryValueCache()"] e5eb2faf_45a2_ac47_3404_8bd4e7eb6817["parse()"] 258ace88_f7c6_412f_9b37_95e1bd249268 -->|calls| e5eb2faf_45a2_ac47_3404_8bd4e7eb6817 a32bba76_f60d_883f_1ff1_276a0bb9db9f["walk()"] 258ace88_f7c6_412f_9b37_95e1bd249268 -->|calls| a32bba76_f60d_883f_1ff1_276a0bb9db9f 7cb24904_9371_1e21_df0f_10f340632987["recursivelyEscapeUnderscores()"] 258ace88_f7c6_412f_9b37_95e1bd249268 -->|calls| 7cb24904_9371_1e21_df0f_10f340632987 c57928e0_95f9_bd68_c036_1186e1a4d345["toCss()"] 258ace88_f7c6_412f_9b37_95e1bd249268 -->|calls| c57928e0_95f9_bd68_c036_1186e1a4d345 style 258ace88_f7c6_412f_9b37_95e1bd249268 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/candidate.ts lines 1033–1088
const printArbitraryValueCache = new DefaultMap<string, string>((input) => {
let ast = ValueParser.parse(input)
let drop = new Set<ValueParser.ValueAstNode>()
walk(ast, (node, ctx) => {
let parentArray = ctx.parent === null ? ast : (ctx.parent.nodes ?? [])
// Handle operators (e.g.: inside of `calc(…)`)
if (
node.kind === 'word' &&
// Operators
(node.value === '+' || node.value === '-' || node.value === '*' || node.value === '/')
) {
let idx = parentArray.indexOf(node) ?? -1
// This should not be possible
if (idx === -1) return
let previous = parentArray[idx - 1]
if (previous?.kind !== 'separator' || previous.value !== ' ') return
let next = parentArray[idx + 1]
if (next?.kind !== 'separator' || next.value !== ' ') return
drop.add(previous)
drop.add(next)
}
// Leading and trailing whitespace
else if (node.kind === 'separator' && node.value.length > 0 && node.value.trim() === '') {
if (parentArray[0] === node || parentArray[parentArray.length - 1] === node) {
drop.add(node)
}
}
// Whitespace around `,` separators can be removed.
// E.g.: `min(1px , 2px)` -> `min(1px,2px)`
else if (node.kind === 'separator' && node.value.trim() === ',') {
node.value = ','
}
})
if (drop.size > 0) {
walk(ast, (node) => {
if (drop.has(node)) {
drop.delete(node)
return WalkAction.ReplaceSkip([])
}
})
}
recursivelyEscapeUnderscores(ast)
return ValueParser.toCss(ast)
})
Domain
Subdomains
Source
Frequently Asked Questions
What does printArbitraryValueCache() do?
printArbitraryValueCache() is a function in the tailwindcss codebase.
What does printArbitraryValueCache() call?
printArbitraryValueCache() calls 4 function(s): parse, recursivelyEscapeUnderscores, toCss, walk.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free