seniority/yaml
Every export of seniority/yaml, with its signature and doc comment: parse, YAMLException, plus 1 type.
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-yaml5 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 YAMLExceptions 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.
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.
function parse(text: string): unknown;| Parameter | Type |
|---|---|
text | string |
Returns unknown
Classes
YAMLException
A document this parser cannot read, with the reason and where.
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.
interface Mark {
line: number;
column: number;
position: number;
}seniority/find-up
Every export of seniority/find-up, with its signature and doc comment: findUpSync, findUpMultipleSync, findUp, findUpMultiple, plus 1 type.
seniority/config
Every export of seniority/config, with its signature and doc comment: deepMerge, lineOf, loadWithExtends, candidates, discover, plus 3 types.