( tag: string, value: unknown, plain: string | undefined, fail: (message: string) => never )
| 371 | // node is a plain scalar; quoted and block scalars are already strings, and an |
| 372 | // empty node is the empty string. |
| 373 | const resolveTag = ( |
| 374 | tag: string, |
| 375 | value: unknown, |
| 376 | plain: string | undefined, |
| 377 | fail: (message: string) => never |
| 378 | ): unknown => { |
| 379 | const collection = typeof value === "object" && value !== null |
| 380 | if (tag === "!!seq" || tag === "!!map") { |
| 381 | if (!collection || Array.isArray(value) !== (tag === "!!seq")) fail(`Node does not match the YAML tag ${tag}`) |
| 382 | return value |
| 383 | } |
| 384 | if (collection) fail(`A collection does not match the YAML tag ${tag}`) |
| 385 | return resolveScalarTag(tag, plain ?? (typeof value === "string" ? value : ""), fail) |
| 386 | } |
| 387 | |
| 388 | const isExplicitKey = (text: string): boolean => |
| 389 | text.charCodeAt(0) === 63 && (text.length === 1 || isWhiteCode(text.charCodeAt(1))) |
no test coverage detected