MCPcopy Create free account
hub / github.com/denoland/std / parse

Function parse

yaml/unstable_parse.ts:61–78  ·  view source on GitHub ↗
(
  content: string,
  options: ParseOptions = {},
)

Source from the content-addressed store, hash-verified

59 * @returns Parsed document.
60 */
61export 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

Callers

nothing calls this directly

Calls 4

readDocumentsMethod · 0.95
getSchemaFunction · 0.90
sanitizeInputFunction · 0.70
nextMethod · 0.45

Tested by

no test coverage detected