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

Method parseSequenceEntry

packages/effect/src/encoding/Yaml.ts:1180–1196  ·  view source on GitHub ↗
(entry: string, separator: number, indent: number, line: Line)

Source from the content-addressed store, hash-verified

1178 // `entry` starts with the `-` indicator, which sits at column `indent` of `line`, and
1179 // `separator` is `mappingSeparator(entry)`.
1180 private parseSequenceEntry(entry: string, separator: number, indent: number, line: Line): unknown {
1181 const item = trimWhiteStart(entry.slice(1))
1182 if (isExplicitKey(item)) this.fail(line, explicitKeyError)
1183 // A compact nested sequence or mapping is indented to its first character,
1184 // which may sit more than one space after the dash.
1185 const offset = entry.length - item.length
1186 // Removing the dash and separation shifts the separator without changing its meaning.
1187 const itemSeparator = separator === -1 ? -1 : separator - offset
1188 const nested = isSequenceEntry(item)
1189 if (!nested && itemSeparator === -1) {
1190 return item.length === 0 ? this.parseBlockValue(indent, false) : this.parseNodeValue(item, indent)
1191 }
1192 if (entry.slice(1, offset).includes("\t")) this.fail(line, "Tabs cannot be used for YAML indentation")
1193 return nested
1194 ? this.parseSequence(indent + offset, { text: item, separator: itemSeparator, line })
1195 : this.parseMapping(indent + offset, { text: item, separator: itemSeparator, line })
1196 }
1197
1198 private enterCollection(): void {
1199 if (++this.depth > maxDepth) throw new SyntaxError(depthError)

Callers 1

parseSequenceMethod · 0.95

Calls 9

failMethod · 0.95
parseBlockValueMethod · 0.95
parseNodeValueMethod · 0.95
parseSequenceMethod · 0.95
parseMappingMethod · 0.95
trimWhiteStartFunction · 0.85
isExplicitKeyFunction · 0.85
isSequenceEntryFunction · 0.85
sliceMethod · 0.80

Tested by

no test coverage detected