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

Method parseKey

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

Source from the content-addressed store, hash-verified

763
764 // Return source text for the same key conversion used in block mappings.
765 private parseKey(): string {
766 this.skipWhitespace()
767 const character = this.peek()
768 if (isPropertyIndicatorCode(character.charCodeAt(0))) this.fail(keyPropertyError)
769 if (character === "\"" || character === "'") return this.readQuoted(character)
770 const text = this.readPlain(isFlowPlainEnd)
771 // A comment or line break may separate the key from its `:`.
772 this.skipWhitespace()
773 if (this.peek() !== ":") {
774 if (text === "") this.expect(":")
775 // Reject `{a:1}` rather than choose between a YAML valueless key and a JSON-like pair.
776 if (text.includes(":")) {
777 this.fail(`Flow mapping key '${text}' has no value, add a space after ':' or quote the key`)
778 }
779 }
780 return text
781 }
782
783 // Read a quoted scalar one line at a time to keep scanning linear.
784 private readQuoted(quote: string): string {

Callers 1

parseMappingEntryMethod · 0.95

Calls 7

skipWhitespaceMethod · 0.95
peekMethod · 0.95
failMethod · 0.95
readQuotedMethod · 0.95
readPlainMethod · 0.95
expectMethod · 0.95
isPropertyIndicatorCodeFunction · 0.85

Tested by

no test coverage detected