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

Function parse

yaml/parse.ts:73–90  ·  view source on GitHub ↗
(
  content: string,
  options: ParseOptions = {},
)

Source from the content-addressed store, hash-verified

71 * @returns Parsed document.
72 */
73export 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

Callers 2

fnFunction · 0.90
parse_test.tsFile · 0.90

Calls 4

readDocumentsMethod · 0.95
sanitizeInputFunction · 0.70
getMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected