spliceChangesIntoString() — tailwindcss Function Reference
Architecture documentation for the spliceChangesIntoString() function in splice-changes-into-string.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 0ad23c56_9291_b80b_7e43_b919fbc7087f["spliceChangesIntoString()"] d8b3b0ab_e770_e110_7520_a6fdabeda83a["splice-changes-into-string.ts"] 0ad23c56_9291_b80b_7e43_b919fbc7087f -->|defined in| d8b3b0ab_e770_e110_7520_a6fdabeda83a 404037a5_0bed_880c_5e9a_954d7ffbf6d7["migrateContents()"] 404037a5_0bed_880c_5e9a_954d7ffbf6d7 -->|calls| 0ad23c56_9291_b80b_7e43_b919fbc7087f style 0ad23c56_9291_b80b_7e43_b919fbc7087f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-upgrade/src/utils/splice-changes-into-string.ts lines 11–42
export function spliceChangesIntoString(str: string, changes: StringChange[]) {
// If there are no changes, return the original string
if (!changes[0]) return str
// Sort all changes in order to make it easier to apply them
changes.sort((a, b) => {
return a.end - b.end || a.start - b.start
})
// Append original string between each chunk, and then the chunk itself
// This is sort of a String Builder pattern, thus creating less memory pressure
let result = ''
let previous = changes[0]
result += str.slice(0, previous.start)
result += previous.replacement
for (let i = 1; i < changes.length; ++i) {
let change = changes[i]
result += str.slice(previous.end, change.start)
result += change.replacement
previous = change
}
// Add leftover string from last chunk to end
result += str.slice(previous.end)
return result
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does spliceChangesIntoString() do?
spliceChangesIntoString() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-upgrade/src/utils/splice-changes-into-string.ts.
Where is spliceChangesIntoString() defined?
spliceChangesIntoString() is defined in packages/@tailwindcss-upgrade/src/utils/splice-changes-into-string.ts at line 11.
What calls spliceChangesIntoString()?
spliceChangesIntoString() is called by 1 function(s): migrateContents.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free