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

Method consume

packages/effect/src/encoding/Xml.ts:1506–1530  ·  view source on GitHub ↗
(chunk: string, force = false)

Source from the content-addressed store, hash-verified

1504 }
1505
1506 private consume(chunk: string, force = false): void {
1507 this.received += chunk.length
1508 if (this.pending !== undefined) {
1509 if (!force && this.scanner.scan(chunk, 0) === -1) {
1510 this.pending.push(chunk)
1511 this.pendingLength += chunk.length
1512 // Joins runs of chunks, so that a token split into many tiny chunks
1513 // does not take an array slot for each
1514 if (++this.pendingAdded === pendingRun) {
1515 this.pending.push(this.pending.splice(-pendingRun).join(""))
1516 this.pendingAdded = 0
1517 }
1518 this.checkPending()
1519 return
1520 }
1521 // Joining makes a flat string, which V8 reads faster than the rope that
1522 // concatenation makes
1523 this.pending.push(chunk)
1524 this.load(this.pending.join(""), this.pendingStart)
1525 this.pending = undefined
1526 } else {
1527 this.load(chunk, this.received - chunk.length)
1528 }
1529 this.parse(false)
1530 }
1531
1532 private load(buf: string, base: number): void {
1533 this.buf = buf

Callers 9

feedMethod · 0.95
RateLimiterTest.tsFile · 0.80
suiteFunction · 0.80
consumeFunction · 0.80
consumeFunction · 0.80
HttpClient.tsFile · 0.80
RateLimiter.tsFile · 0.80
sleepFunction · 0.80

Calls 6

checkPendingMethod · 0.95
loadMethod · 0.95
parseMethod · 0.95
pushMethod · 0.65
scanMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected