MCPcopy Create free account
hub / github.com/Effect-TS/effect / parseDirectives

Method parseDirectives

packages/effect/src/encoding/Yaml.ts:1027–1049  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1025
1026 // YAML 1.2.2 §6.8: only `%YAML 1.2` is supported, and directives must be followed by `---`.
1027 private parseDirectives(): void {
1028 let version = false
1029 while (true) {
1030 this.skipIgnored()
1031 const line = this.lines[this.index]
1032 if (line === undefined || line.indent !== 0 || !line.text.startsWith("%")) break
1033 const [name, ...parameters] = boundaryContent(line.raw.slice(1)).split(/[ \t]+/)
1034 if (name === "YAML") {
1035 if (version) this.fail(line, "Duplicate %YAML directive")
1036 if (parameters.length !== 1 || parameters[0] !== "1.2") {
1037 this.fail(line, `Unsupported YAML version '${parameters.join(" ")}', only 1.2 is supported`)
1038 }
1039 version = true
1040 } else {
1041 this.fail(line, `Unsupported YAML directive '%${name}'`)
1042 }
1043 this.index++
1044 }
1045 const next = this.lines[this.index]
1046 if (next === undefined || !isDocumentStart(next)) {
1047 this.fail(next ?? this.lines[this.index - 1], "Expected '---' after YAML directives")
1048 }
1049 }
1050
1051 private parseDocument(): unknown {
1052 const start = this.lines[this.index]

Callers 1

parseStreamMethod · 0.95

Calls 7

skipIgnoredMethod · 0.95
failMethod · 0.95
boundaryContentFunction · 0.85
isDocumentStartFunction · 0.85
sliceMethod · 0.80
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected