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 c36514d1_be3d_c915_4996_66befada0375["spliceChangesIntoString()"] 079e0035_1ce3_3d9d_3017_71b47a7375a1["migrateContents()"] 079e0035_1ce3_3d9d_3017_71b47a7375a1 -->|calls| c36514d1_be3d_c915_4996_66befada0375 style c36514d1_be3d_c915_4996_66befada0375 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.
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