(
content: string,
options: ParseOptions = {},
)
| 71 | * @returns Parsed document. |
| 72 | */ |
| 73 | export function parse( |
| 74 | content: string, |
| 75 | options: ParseOptions = {}, |
| 76 | ): unknown { |
| 77 | content = sanitizeInput(content); |
| 78 | const state = new LoaderState(content, { |
| 79 | ...options, |
| 80 | schema: SCHEMA_MAP.get(options.schema!)!, |
| 81 | }); |
| 82 | const documentGenerator = state.readDocuments(); |
| 83 | const document = documentGenerator.next().value; |
| 84 | if (!documentGenerator.next().done) { |
| 85 | throw new SyntaxError( |
| 86 | "Found more than 1 document in the stream: expected a single document", |
| 87 | ); |
| 88 | } |
| 89 | return document ?? null; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Same as {@linkcode parse}, but understands multi-document YAML sources, and |
no test coverage detected