# tools/core/analyzers/checklist.analyzer.ts

> 39 lines of code and 8 definitions.

Tree: Coordination tree
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tools-core-analyzers-checklist-analyzer-ts
Source text: https://banes-lab.com/assets/sources/source.0efb47efdbb0a11c295d59b412ae814ca1e6011584bd6ffe229886a05bb32dea.generated.txt

## Definitions

- `close` (lexical_declaration, line 17, exported)
- `phaseSpans` (lexical_declaration, line 10, exported)
- `PhaseSpan` (interface_declaration, line 3, exported)
- `out` (lexical_declaration, line 11, exported)
- `title` (lexical_declaration, line 12, exported)
- `start` (lexical_declaration, line 13, exported)
- `body` (lexical_declaration, line 14, exported)
- `band` (lexical_declaration, line 15, exported)

## Source

```typescript
import { MILESTONE_MARKER, PHASE_MARKER } from "../constants/checklist.constants.ts";

export interface PhaseSpan {
    readonly title: string;
    readonly line: number;
    readonly text: string;
    readonly band: string;
}

export const phaseSpans = function phaseSpans(lines: readonly string[]): PhaseSpan[] {
    const out: PhaseSpan[] = [];
    let title = "";
    let start = -1;
    let body: string[] = [];
    let band: string[] = [];

    const close = (): void => {
        if (start === -1) {
            return;
        }
        out.push({ band: band.join("\n"), line: start + 1, text: body.join("\n"), title });
    };

    for (const [index, line] of lines.entries()) {
        if (line.startsWith(PHASE_MARKER)) {
            close();
            title = line.slice(PHASE_MARKER.length).trim();
            start = index;
            body = [];
        } else if (line.startsWith(MILESTONE_MARKER)) {
            close();
            start = -1;
            body = [];
            band = [];
        } else if (start === -1) {
            band.push(line);
        } else {
            body.push(line);
        }
    }

    close();
    return out;
};
```
