| 251 | * parsed body, or null when the fragment does not parse to a single-key map. |
| 252 | */ |
| 253 | export const parseEntry = ( |
| 254 | text: string, |
| 255 | range: ByteRange, |
| 256 | indent: number, |
| 257 | ): readonly [string, unknown] | null => { |
| 258 | const parsed = parseYaml(dedent(text.slice(range.start, range.end), indent)); |
| 259 | if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null; |
| 260 | const entries = Object.entries(parsed as Record<string, unknown>); |
| 261 | if (entries.length !== 1) return null; |
| 262 | return entries[0]!; |
| 263 | }; |
| 264 | |
| 265 | /** Parse the concatenation of the head ranges into the document head (openapi, |
| 266 | * info, servers, tags). Small; safe to materialize whole. */ |