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

Method parseBlockKey

packages/effect/src/encoding/Yaml.ts:1142–1155  ·  view source on GitHub ↗
(raw: string, fail: (message: string) => never)

Source from the content-addressed store, hash-verified

1140
1141 // The key's source text, from `raw` before the `:` separator.
1142 private parseBlockKey(raw: string, fail: (message: string) => never): string {
1143 const text = trimWhite(raw)
1144 if (isPropertyIndicatorCode(text.charCodeAt(0))) fail(keyPropertyError)
1145 if (text.startsWith("%")) fail(directiveIndicatorError)
1146 // YAML 1.2.2 §7.3.3: `?` directly before the `:` separator starts a plain key. `raw` ends at
1147 // the separator, so it ends with `?` only then.
1148 if (isExplicitKey(text) && !(text === "?" && raw.endsWith("?"))) fail(explicitKeyError)
1149 // YAML 1.2.2 §7.3: a quoted key ends at its closing quote, and only white space may follow it.
1150 const quote = text[0]
1151 if ((quote === "\"" || quote === "'") && closingQuote(text, quote, 1) !== text.length - 1) {
1152 fail("Unexpected content after quoted YAML key")
1153 }
1154 return text
1155 }
1156
1157 // `first` is the entry of a compact nested sequence (`- - item`), which starts on its parent entry's line.
1158 private parseSequence(

Callers 1

parseMappingEntryMethod · 0.95

Calls 5

trimWhiteFunction · 0.85
isPropertyIndicatorCodeFunction · 0.85
isExplicitKeyFunction · 0.85
closingQuoteFunction · 0.85
failFunction · 0.70

Tested by

no test coverage detected