def eol

bend-kit-llm@0.13.0.1 · sse.bend:44

import bend-kit-llm@0.13.0.1/sse.bend as Sse
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

44# The first CR or LF at or after i, or the end. f counts the bytes from i to the end; r holds byte i.
45def eol(f: Nat, r: Array<U32> & U32, +i: U32) -> Array<U32> & U32:
46  match f:
47    case 0n:
48      (a, c) = r
49      (a, i)
50    case 1n+p:
51      (a, +c) = r
52      match c:
53        case 10:
54          (a, i)
55        case 13:
56          (a, i)
57        case _:
58          eol(p, Bytes.peek(a, (i + 1 : U32)), (i + 1 : U32))

Uses (10)

Used by (1)