A mapping on one line: "repo `x`; rev `y`; hooks (1): `black` (exclude `z`)".
(value: Extract<YamlValue, { kind: 'map' }>, depth: number, words: Words)
| 145 | |
| 146 | /** A mapping on one line: "repo `x`; rev `y`; hooks (1): `black` (exclude `z`)". */ |
| 147 | function inlineMap(value: Extract<YamlValue, { kind: 'map' }>, depth: number, words: Words): string { |
| 148 | if (!value.entries.length) return words.empty; |
| 149 | return value.entries.slice(0, FIELDS).map(([key, item]) => field(key, item, depth, words)).join('; ') + more(value.entries.length, FIELDS, words); |
| 150 | } |
| 151 | function field(key: string, value: YamlValue, depth: number, words: Words): string { |
| 152 | if (value.kind === 'scalar') return `${key} ${scalarText(value, words)}`; |
| 153 | if (value.kind === 'map') return depth < 2 ? `${key}: ${inlineMap(value, depth + 1, words)}` : `${key} (${words.keys(value.entries.length)})`; |
no test coverage detected