MCPcopy
hub / github.com/tailwindlabs/tailwindcss / isVariableUsed

Function isVariableUsed

packages/tailwindcss/src/ast.ts:906–932  ·  view source on GitHub ↗
(
  variable: string,
  theme: Theme,
  variableDependencies: Map<string, Set<string>>,
  alreadySeenVariables: Set<string> = new Set(),
)

Source from the content-addressed store, hash-verified

904// Find out if a variable is either used directly or if any of the variables that depend on it are
905// used
906function isVariableUsed(
907 variable: string,
908 theme: Theme,
909 variableDependencies: Map<string, Set<string>>,
910 alreadySeenVariables: Set<string> = new Set(),
911): boolean {
912 // Break recursions when visiting a variable twice
913 if (alreadySeenVariables.has(variable)) {
914 return true
915 } else {
916 alreadySeenVariables.add(variable)
917 }
918
919 let options = theme.getOptions(variable)
920 if (options & (ThemeOptions.STATIC | ThemeOptions.USED)) {
921 return true
922 } else {
923 let dependencies = variableDependencies.get(variable) ?? []
924 for (let dependency of dependencies) {
925 if (isVariableUsed(dependency, theme, variableDependencies, alreadySeenVariables)) {
926 return true
927 }
928 }
929 }
930
931 return false
932}
933
934function extractKeyframeNames(value: string): string[] {
935 return value.split(/[\s,]+/)

Callers 1

optimizeAstFunction · 0.85

Calls 4

getOptionsMethod · 0.80
hasMethod · 0.45
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected