(
content: string,
options: ParseOptions = {},
)
| 59 | * @returns Parsed document. |
| 60 | */ |
| 61 | export function parse( |
| 62 | content: string, |
| 63 | options: ParseOptions = {}, |
| 64 | ): unknown { |
| 65 | content = sanitizeInput(content); |
| 66 | const state = new LoaderState(content, { |
| 67 | ...options, |
| 68 | schema: getSchema(options.schema, options.extraTypes), |
| 69 | }); |
| 70 | const documentGenerator = state.readDocuments(); |
| 71 | const document = documentGenerator.next().value; |
| 72 | if (!documentGenerator.next().done) { |
| 73 | throw new SyntaxError( |
| 74 | "Found more than 1 document in the stream: expected a single document", |
| 75 | ); |
| 76 | } |
| 77 | return document ?? null; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Same as {@linkcode parse}, but understands multi-document YAML sources, and |
nothing calls this directly
no test coverage detected