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

Method readUntil

packages/effect/src/encoding/Yaml.ts:832–852  ·  view source on GitHub ↗
(stop: (code: number) => boolean, plain = false)

Source from the content-addressed store, hash-verified

830 // `plain` reads a plain scalar, which also stops at a `:` that separates a key from its
831 // value and at the end of a line a comment ended.
832 private readUntil(stop: (code: number) => boolean, plain = false): string {
833 this.afterJsonNode = false
834 // Only text spanning lines needs pieces; most tokens are one slice of one line.
835 let pieces: Array<string> | undefined
836 let start = this.index
837 while (true) {
838 if (this.index === this.line.length) {
839 const piece = this.line.slice(start)
840 if (this.depth === 0 || (plain && this.comment) || !this.nextChunk(plain ? "plain" : "token")) {
841 return pieces === undefined ? piece : pieces.join("") + piece
842 }
843 ;(pieces ??= []).push(piece)
844 start = 0
845 }
846 const code = this.line.charCodeAt(this.index)
847 if (stop(code) || (plain && code === 58 && this.isValueSeparator())) break
848 this.index++
849 }
850 const piece = this.line.slice(start, this.index)
851 return pieces === undefined ? piece : pieces.join("") + piece
852 }
853
854 // YAML 1.2.2 §7.3.3: in flow context, a `:` followed by white space, a line break or a flow
855 // indicator separates a key from its value. Any other `:` is part of a plain scalar.

Callers 4

parseValueMethod · 0.95
parseTaggedValueMethod · 0.95
readPlainMethod · 0.95
readTagTokenMethod · 0.95

Calls 6

nextChunkMethod · 0.95
isValueSeparatorMethod · 0.95
sliceMethod · 0.80
pushMethod · 0.65
stopFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected