# tools/core/inspectors/index.inspector.ts

> 43 lines of code and 13 definitions.

Tree: Coordination tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tools-core-inspectors-index-inspector-ts
Source text: https://banes-lab.com/assets/sources/source.bd88cf3d6a5d89b79bb5c71341cb0c1211a0068342b1cc4a22f5ad8dc9714ebd.generated.txt

## Definitions

- `isSeatLetter` (lexical_declaration, line 26)
- `rowsOf` (lexical_declaration, line 12)
- `isCapital` (lexical_declaration, line 22)
- `activeSeatLetters` (lexical_declaration, line 34, exported)
- `indexedStates` (lexical_declaration, line 40, exported)
- `isIndexedLetter` (lexical_declaration, line 30)
- `ROW` (lexical_declaration, line 1)
- `ACTIVE_STATE` (lexical_declaration, line 3)
- `HEADER_CELL` (lexical_declaration, line 5)
- `IndexRow` (interface_declaration, line 7)
- `cells` (lexical_declaration, line 17)
- `indexedLetters` (lexical_declaration, line 48, exported)
- `listed` (lexical_declaration, line 49, exported)

## Source

```typescript
const ROW = "| ";

const ACTIVE_STATE = "ACTIVE";

const HEADER_CELL = "letter";

interface IndexRow {
    readonly letter: string;
    readonly state: string;
}

const rowsOf = function rowsOf(index: string): IndexRow[] {
    return index
        .split("\n")
        .filter((line) => line.startsWith(ROW))
        .map((line) => {
            const cells = line.split("|");
            return { letter: (cells[1] ?? "").trim(), state: (cells[3] ?? "").trim() };
        });
};

const isCapital = function isCapital(char: string): boolean {
    return char >= "A" && char <= "Z";
};

const isSeatLetter = function isSeatLetter(letter: string): boolean {
    return letter.length === 1 && isCapital(letter);
};

const isIndexedLetter = function isIndexedLetter(letter: string): boolean {
    return letter.length > 0 && letter !== HEADER_CELL && isCapital(letter.charAt(0));
};

export const activeSeatLetters = function activeSeatLetters(index: string): string[] {
    return rowsOf(index)
        .filter((row) => isSeatLetter(row.letter) && row.state === ACTIVE_STATE)
        .map((row) => row.letter);
};

export const indexedStates = function indexedStates(index: string): Map<string, string> {
    return new Map(
        rowsOf(index)
            .filter((row) => isSeatLetter(row.letter) && row.state.length > 0)
            .map((row) => [row.letter, row.state]),
    );
};

export const indexedLetters = function indexedLetters(index: string): { letters: Set<string>; duplicates: string[] } {
    const listed = rowsOf(index)
        .map((row) => row.letter)
        .filter(isIndexedLetter);

    return { duplicates: listed.filter((letter, at) => listed.indexOf(letter) !== at), letters: new Set(listed) };
};
```
