MCPcopy
hub / github.com/vercel/next.js / css

Function css

packages/next/src/next-devtools/dev-overlay/utils/css.ts:1–24  ·  view source on GitHub ↗
(
  strings: TemplateStringsArray,
  ...keys: readonly string[]
)

Source from the content-addressed store, hash-verified

1export function css(
2 strings: TemplateStringsArray,
3 ...keys: readonly string[]
4): string {
5 const lastIndex = strings.length - 1
6 const str =
7 // Convert template literal into a single line string
8 strings.slice(0, lastIndex).reduce((p, s, i) => p + s + keys[i], '') +
9 strings[lastIndex]
10
11 return (
12 str
13 // Remove comments
14 .replace(/\/\*[\s\S]*?\*\//g, '')
15 // Remove whitespace, tabs, and newlines
16 .replace(/\s+/g, ' ')
17 // Remove spaces before and after semicolons, and spaces after commas
18 .replace(/\s*([:;,{}])\s*/g, '$1')
19 // Remove extra semicolons
20 .replace(/;+}/g, '}')
21 // Trim leading and trailing whitespaces
22 .trim()
23 )
24}

Callers 15

call-stack.tsxFile · 0.90
DevToolsHeaderFunction · 0.90
overlay.tsxFile · 0.90
StatusIndicatorFunction · 0.90
NextLogoFunction · 0.90
styles.tsxFile · 0.90
styles.tsFile · 0.90
css.test.tsFile · 0.90
ComponentStylesFunction · 0.90
FontStylesFunction · 0.90

Calls 4

reduceMethod · 0.80
trimMethod · 0.80
replaceMethod · 0.65
sliceMethod · 0.45

Tested by

no test coverage detected