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

Function parseSrcset

packages/@tailwindcss-node/src/urls.ts:174–186  ·  view source on GitHub ↗
(string: string)

Source from the content-addressed store, hash-verified

172}
173
174function parseSrcset(string: string): ImageCandidate[] {
175 const matches = string
176 .trim()
177 .replace(escapedSpaceCharactersRE, ' ')
178 .replace(/\r?\n/, '')
179 .replace(/,\s+/, ', ')
180 .replaceAll(/\s+/g, ' ')
181 .matchAll(imageCandidateRE)
182 return Array.from(matches, ({ groups }) => ({
183 url: groups?.url?.trim() ?? '',
184 descriptor: groups?.descriptor?.trim() ?? '',
185 })).filter(({ url }) => !!url)
186}
187
188function joinSrcset(ret: ImageCandidate[]) {
189 return ret.map(({ url, descriptor }) => url + (descriptor ? ` ${descriptor}` : '')).join(', ')

Callers 1

processSrcSetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected