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

Function asyncReplace

packages/@tailwindcss-node/src/urls.ts:192–207  ·  view source on GitHub ↗
(
  input: string,
  re: RegExp,
  replacer: (match: RegExpExecArray) => string | Promise<string>,
)

Source from the content-addressed store, hash-verified

190}
191
192async function asyncReplace(
193 input: string,
194 re: RegExp,
195 replacer: (match: RegExpExecArray) => string | Promise<string>,
196): Promise<string> {
197 let match: RegExpExecArray | null
198 let remaining = input
199 let rewritten = ''
200 while ((match = re.exec(remaining))) {
201 rewritten += remaining.slice(0, match.index)
202 rewritten += await replacer(match)
203 remaining = remaining.slice(match.index + match[0].length)
204 }
205 rewritten += remaining
206 return rewritten
207}

Callers 2

rewriteCssUrlsFunction · 0.85
rewriteCssImageSetFunction · 0.85

Calls 2

replacerFunction · 0.85
execMethod · 0.80

Tested by

no test coverage detected