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

Method parseSequence

packages/effect/src/unstable/encoding/Yaml.ts:381–413  ·  view source on GitHub ↗
(indent: number)

Source from the content-addressed store, hash-verified

379 }
380
381 private parseSequence(indent: number): Array<unknown> {
382 const output: Array<unknown> = []
383 while (true) {
384 this.skipIgnored()
385 const line = this.lines[this.index]
386 if (line === undefined || line.indent < indent) return output
387 if (line.indent > indent) this.fail(line, `Unexpected indentation of ${line.indent} spaces`)
388 if (line.text !== "-" && !line.text.startsWith("- ")) return output
389 this.index++
390 const item = line.text.slice(1).trimStart()
391 const separator = mappingSeparator(item)
392 if (separator === -1) {
393 output.push(this.parseNodeValue(item, indent))
394 continue
395 }
396
397 const mapping: YamlRecord = {}
398 this.parseMappingEntry(mapping, item, separator, indent + 2, line)
399 while (true) {
400 this.skipIgnored()
401 const continuation = this.lines[this.index]
402 if (continuation === undefined || continuation.indent <= indent) break
403 if (continuation.indent !== indent + 2) {
404 this.fail(continuation, `Expected indentation of ${indent + 2} spaces`)
405 }
406 const nextSeparator = mappingSeparator(continuation.text)
407 if (nextSeparator === -1) this.fail(continuation, "Expected a mapping entry")
408 this.index++
409 this.parseMappingEntry(mapping, continuation.text, nextSeparator, indent + 2, continuation)
410 }
411 output.push(mapping)
412 }
413 }
414
415 private parseNodeValue(rawValue: string, parentIndent: number): unknown {
416 let value = rawValue

Callers 1

parseNodeMethod · 0.95

Calls 6

skipIgnoredMethod · 0.95
failMethod · 0.95
parseNodeValueMethod · 0.95
parseMappingEntryMethod · 0.95
mappingSeparatorFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected