# seniority/yaml

> Every export of seniority/yaml, with its signature and doc comment: parse, YAMLException, plus 1 type.

Source: https://seniority.interlace.tools/docs/api/yaml

<!-- Generated by scripts/api-reference.ts from the built dist/*.d.ts. Do not edit; run `npx tsx scripts/api-reference.ts`. -->
<!-- markdownlint-disable-file MD038 -- a doc comment quotes a code span that opens or closes on a space -->

YAML for configuration files, with no dependency (D-20260930-seniority-yaml).

`parse(text)` returns what `js-yaml`'s `load(text)` returns — the value `cosmiconfig` hands
its caller for a `.yaml`, a `.yml` or an extensionless rc file — for the part of YAML 1.2
that a configuration file is written in:

- block mappings and sequences, including a sequence at its key's own indentation and a
  mapping written inline after `- `;
- flow `[…]` and `{…}`, nested and across lines;
- plain scalars, one line or folded over several; single- and double-quoted scalars with
  every YAML escape; `|` and `>` block scalars with chomping and an indentation indicator;
- comments, `---` / `...` document markers, directives (skipped), anchors and aliases;
- the core schema `js-yaml` 5 loads by default: `null`, booleans, integers (`0x`, `0o`),
  floats (`.inf`, `.nan`) and strings, and the `!!str` / `!!int` / … tags that force one.

Merge keys (`<<`) are an ordinary key here because they are in js-yaml 5's default load too:
its `CORE_SCHEMA` leaves `!!merge` out. What this does **not** read is refused by name with
the line and column — explicit `? ` keys and custom tags — never guessed at. A document is one
document: a second `---` with content is the same error `load` throws.

The errors are `YAMLException`s whose message is js-yaml's: the reason, then `(line:column)`,
1-based. cosmiconfig prefixes `YAML Error in <file>:` and its own suite asserts the result,
so the wording is the contract and is kept word for word where js-yaml has a word for it.

Nothing here imports anything, and no other module in the package imports this one
(`shape.test.ts` holds both halves of that): a program that reads no YAML never loads it.

```ts
import { parse, YAMLException } from 'seniority/yaml';
```

## Functions

### parse

Read one YAML document into plain values. Throws `YAMLException` for anything outside the
subset above, and for input that is not YAML at all.

```ts
function parse(text: string): unknown;
```

| Parameter | Type |
| :-- | :-- |
| `text` | `string` |

**Returns** `unknown`

## Classes

### YAMLException

A document this parser cannot read, with the reason and where.

```ts
class YAMLException extends Error {
    readonly reason: string;
    readonly mark: Mark | undefined;
    constructor(reason: string, mark?: Mark, snippet?: string);
}
```

## Interfaces

### Mark

Where an error is, 0-based, in the shape of js-yaml's `mark`.

```ts
interface Mark {
    line: number;
    column: number;
    position: number;
}
```
