guess_indent() — svelte Function Reference
Architecture documentation for the guess_indent() function in index.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 1f024bba_e234_50f7_06ff_985b932d38fb["guess_indent()"] 5ebe02ec_5012_d775_8472_323790aea285["index.js"] 1f024bba_e234_50f7_06ff_985b932d38fb -->|defined in| 5ebe02ec_5012_d775_8472_323790aea285 5dc393cd_abf0_c68d_c112_9c9be4676889["migrate()"] 5dc393cd_abf0_c68d_c112_9c9be4676889 -->|calls| 1f024bba_e234_50f7_06ff_985b932d38fb f77d781d_88c7_9f52_c690_b336fa2b2ee2["template.SvelteSelf()"] f77d781d_88c7_9f52_c690_b336fa2b2ee2 -->|calls| 1f024bba_e234_50f7_06ff_985b932d38fb style 1f024bba_e234_50f7_06ff_985b932d38fb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/migrate/index.js lines 1972–1996
function guess_indent(content) {
const lines = content.split('\n');
const tabbed = lines.filter((line) => /^\t+/.test(line));
const spaced = lines.filter((line) => /^ {2,}/.test(line));
if (tabbed.length === 0 && spaced.length === 0) {
return '\t';
}
// More lines tabbed than spaced? Assume tabs, and
// default to tabs in the case of a tie (or nothing
// to go on)
if (tabbed.length >= spaced.length) {
return '\t';
}
// Otherwise, we need to guess the multiple
const min = spaced.reduce((previous, current) => {
const count = /^ +/.exec(current)?.[0].length ?? 0;
return Math.min(count, previous);
}, Infinity);
return ' '.repeat(min);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does guess_indent() do?
guess_indent() is a function in the svelte codebase, defined in packages/svelte/src/compiler/migrate/index.js.
Where is guess_indent() defined?
guess_indent() is defined in packages/svelte/src/compiler/migrate/index.js at line 1972.
What calls guess_indent()?
guess_indent() is called by 2 function(s): migrate, template.SvelteSelf.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free