The keys at `level`, each with the lines below it as its value; an item's own "- key" line leads.
(lines: readonly Line[], indexes: readonly number[], level: number)
| 110 | } |
| 111 | /** The keys at `level`, each with the lines below it as its value; an item's own "- key" line leads. */ |
| 112 | function mappingOf(lines: readonly Line[], indexes: readonly number[], level: number): YamlValue { |
| 113 | const keys = indexes.filter((index, at) => lines[index].keyIndent === level && lines[index].key !== undefined && (at === 0 || !lines[index].dash)); |
| 114 | return { kind: 'map', entries: keys.map((key, at): [string, YamlValue] => { |
| 115 | const body = indexes.filter(index => index > key && index < (keys[at + 1] ?? Infinity)); |
| 116 | const line = lines[key]; |
| 117 | return [line.key!, line.value ? scalarOf(line.value) : valueOf(lines, body)]; |
| 118 | }) }; |
| 119 | } |
| 120 | /** The whole file as values, for an outline read from it (C7). */ |
| 121 | export function yamlTree(text: string): YamlValue | undefined { |
| 122 | const lines = linesOf(text); |