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

Method count

packages/effect/src/encoding/Xml.ts:1472–1496  ·  view source on GitHub ↗
(to: number)

Source from the content-addressed store, hash-verified

1470 // Counting resumes only where parsing stopped, which is never between a CR
1471 // and an LF.
1472 private count(to: number): void {
1473 const s = this.buf
1474 const base = this.base
1475 const i = this.counted - base
1476 if (i >= to) return
1477 let cr = this.nextCR === -1 ? indexOrEnd(s, "\r", i) : this.nextCR
1478 let lf = this.nextLF === -1 ? indexOrEnd(s, "\n", i) : this.nextLF
1479 while (true) {
1480 if (cr < to && cr < lf) {
1481 this.line++
1482 this.lineStart = base + cr + 1
1483 cr = indexOrEnd(s, "\r", cr + 1)
1484 } else if (lf < to) {
1485 // The LF of a CRLF does not start a new line
1486 if (!(lf > 0 && s.charCodeAt(lf - 1) === CR)) this.line++
1487 this.lineStart = base + lf + 1
1488 lf = indexOrEnd(s, "\n", lf + 1)
1489 } else {
1490 break
1491 }
1492 }
1493 this.nextCR = cr
1494 this.nextLF = lf
1495 this.counted = base + to
1496 }
1497
1498 private syntax(message: string, i: number): XmlError {
1499 return this.error("Syntax", message, this.base + i)

Callers 3

errorMethod · 0.95
parseMethod · 0.95
startTagMethod · 0.95

Calls 1

indexOrEndFunction · 0.85

Tested by

no test coverage detected