Home / File/ math-operators.ts — tailwindcss Source File

math-operators.ts — tailwindcss Source File

Architecture documentation for math-operators.ts, a typescript file in the tailwindcss codebase. 0 imports, 2 dependents.

File typescript Oxide Extractor 2 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  27cd040f_e3a9_f8b7_3c7c_0547b201eeb0["math-operators.ts"]
  7df4d001_f01e_1e05_13ee_91edb05bf1f8["decode-arbitrary-value.ts"]
  7df4d001_f01e_1e05_13ee_91edb05bf1f8 --> 27cd040f_e3a9_f8b7_3c7c_0547b201eeb0
  43fe4735_10e8_ed1d_6f4f_74b2008c1b00["infer-data-type.ts"]
  43fe4735_10e8_ed1d_6f4f_74b2008c1b00 --> 27cd040f_e3a9_f8b7_3c7c_0547b201eeb0
  style 27cd040f_e3a9_f8b7_3c7c_0547b201eeb0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

const LOWER_A = 0x61
const LOWER_Z = 0x7a
const UPPER_A = 0x41
const UPPER_Z = 0x5a
const LOWER_E = 0x65
const UPPER_E = 0x45
const ZERO = 0x30
const NINE = 0x39
const ADD = 0x2b
const SUB = 0x2d
const MUL = 0x2a
const DIV = 0x2f
const OPEN_PAREN = 0x28
const CLOSE_PAREN = 0x29
const COMMA = 0x2c
const SPACE = 0x20
const PERCENT = 0x25

const MATH_FUNCTIONS = [
  'calc',
  'min',
  'max',
  'clamp',
  'mod',
  'rem',
  'sin',
  'cos',
  'tan',
  'asin',
  'acos',
  'atan',
  'atan2',
  'pow',
  'sqrt',
  'hypot',
  'log',
  'exp',
  'round',
]

export function hasMathFn(input: string) {
  return input.indexOf('(') !== -1 && MATH_FUNCTIONS.some((fn) => input.includes(`${fn}(`))
}

export function addWhitespaceAroundMathOperators(input: string) {
  // Bail early if there are no math functions in the input
  if (!MATH_FUNCTIONS.some((fn) => input.includes(fn))) {
    return input
  }

  let result = ''
  let formattable: boolean[] = []

  let valuePos = null
  let lastValuePos = null

  for (let i = 0; i < input.length; i++) {
    let char = input.charCodeAt(i)

    // Track if we see a number followed by a unit, then we know for sure that
// ... (146 more lines)

Domain

Subdomains

Frequently Asked Questions

What does math-operators.ts do?
math-operators.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the Oxide domain, Extractor subdomain.
What functions are defined in math-operators.ts?
math-operators.ts defines 2 function(s): addWhitespaceAroundMathOperators, hasMathFn.
What files import math-operators.ts?
math-operators.ts is imported by 2 file(s): decode-arbitrary-value.ts, infer-data-type.ts.
Where is math-operators.ts in the architecture?
math-operators.ts is located at packages/tailwindcss/src/utils/math-operators.ts (domain: Oxide, subdomain: Extractor, directory: packages/tailwindcss/src/utils).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free