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

Method parseValue

packages/effect/src/encoding/Yaml.ts:1247–1269  ·  view source on GitHub ↗
(value: string, parentIndent: number, allowIndentless: boolean)

Source from the content-addressed store, hash-verified

1245 }
1246
1247 private parseValue(value: string, parentIndent: number, allowIndentless: boolean): unknown {
1248 const text = trimWhiteEnd(value)
1249 if (text.length === 0) return this.parseBlockValue(parentIndent, allowIndentless)
1250 if (text.startsWith("!")) throw new SyntaxError("Multiple tags on one node")
1251 if (isExplicitKey(text)) throw new SyntaxError(explicitKeyError)
1252 // YAML 1.2.2 §8.2.1: a block sequence never starts after a key or an anchor on the same line.
1253 if (isSequenceEntry(text)) {
1254 throw new SyntaxError("A block sequence cannot start on the same line as a mapping key or anchor")
1255 }
1256 const first = text.charCodeAt(0)
1257 if ((first === 124 || first === 62) && /^[|>](?:[1-9]?[+-]?|[+-]?[1-9]?)$/.test(text)) {
1258 return this.parseBlockScalar(text, parentIndent)
1259 }
1260 if (value.startsWith("\"") || value.startsWith("'")) return this.parseQuotedValue(value, parentIndent)
1261 if (text.startsWith("*")) {
1262 const name = trimWhite(text.slice(1))
1263 if (!this.anchors.has(name)) throw new SyntaxError(`Unknown YAML alias '*${name}'`)
1264 return this.anchors.get(name)
1265 }
1266 // The untrimmed value keeps an escaped trailing space before a quoted line break.
1267 if (text.startsWith("[") || text.startsWith("{")) return this.parseFlowValue(value, parentIndent)
1268 return this.parsePlainValue(text, parentIndent)
1269 }
1270
1271 // The node on the lines after a value that is empty on its own line.
1272 private parseBlockValue(parentIndent: number, allowIndentless: boolean): unknown {

Callers 1

parseNodeValueMethod · 0.95

Calls 12

parseBlockValueMethod · 0.95
parseBlockScalarMethod · 0.95
parseQuotedValueMethod · 0.95
parseFlowValueMethod · 0.95
parsePlainValueMethod · 0.95
trimWhiteEndFunction · 0.85
isExplicitKeyFunction · 0.85
isSequenceEntryFunction · 0.85
trimWhiteFunction · 0.85
sliceMethod · 0.80
hasMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected