# tools/core/formatters/agenda.formatter.ts

> 41 lines of code and 9 definitions.

Tree: Coordination tree
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tools-core-formatters-agenda-formatter-ts
Source text: https://banes-lab.com/source/coordination/tools/core/formatters/agenda.formatter.ts.txt

Listed in [tools/core/formatters](https://banes-lab.com/api/source/coordination/tools/core/formatters.md), before [tools/core/formatters/board.formatter.ts](https://banes-lab.com/source/coordination/tools/core/formatters/board.formatter.ts.md).

## Definitions

- `oneLine` (lexical_declaration, line 7, exported)
- `invariantCell` (lexical_declaration, line 27)
- `stateCell` (lexical_declaration, line 32)
- `renderSchedule` (lexical_declaration, line 41, exported)
- `CELL_BREAKS` (lexical_declaration, line 5)
- `out` (lexical_declaration, line 8, exported)
- `pending` (lexical_declaration, line 9, exported)
- `named` (lexical_declaration, line 28)
- `{ note }` (lexical_declaration, line 33)

## Source

```typescript
import { SCHEDULE_DIVIDER, SCHEDULE_HEADER } from "../constants/agenda.constants.ts";
import type { SchedulePlan } from "../../../config/agenda.config.ts";
import type { ScheduleReading } from "../types/agenda.types.ts";

const CELL_BREAKS: ReadonlySet<string> = new Set(["\n", "\r", "\t", " "]);

export const oneLine = function oneLine(value: string): string {
    let out = "";
    let pending = false;

    for (const character of value) {
        if (CELL_BREAKS.has(character)) {
            pending = out.length > 0;
            continue;
        }

        if (pending) {
            out += " ";
        }
        pending = false;
        out += character;
    }

    return out;
};

const invariantCell = function invariantCell(plan: SchedulePlan): string {
    const named = `\`${plan.invariant}\``;
    return plan.merged === undefined ? named : `${named} **merged with** \`${plan.merged}\``;
};

const stateCell = function stateCell(reading: ScheduleReading): string {
    const { note } = reading.plan;
    if (note === undefined || note.length === 0) {
        return reading.state;
    }

    return `\`${reading.state}\` — ${note}`;
};

export const renderSchedule = function renderSchedule(readings: readonly ScheduleReading[]): string[] {
    return [
        SCHEDULE_HEADER,
        SCHEDULE_DIVIDER,
        ...readings.map(
            (reading) =>
                `| ${oneLine(reading.plan.ordinal)} | ${oneLine(invariantCell(reading.plan))} | ${oneLine(reading.plan.establishes)} | ${oneLine(stateCell(reading))} |`,
        ),
    ];
};
```
