mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
16 lines
346 B
TypeScript
16 lines
346 B
TypeScript
export const calculateNestingLevel = (code: string): number => {
|
|
let maxNesting = 0
|
|
let currentNesting = 0
|
|
|
|
for (const char of code) {
|
|
if (char === '{') {
|
|
currentNesting++
|
|
maxNesting = Math.max(maxNesting, currentNesting)
|
|
} else if (char === '}') {
|
|
currentNesting--
|
|
}
|
|
}
|
|
|
|
return maxNesting
|
|
}
|