def read_line.unended

bend-stdio-pipes@0.2.0.0 · impl.bend:47

import bend-stdio-pipes@0.2.0.0/impl.bend as Impl
import Base

47# The line of a piece that ends with its LF: the piece without the LF, and the CR before it, if any.
48def read_line.unended(+piece: String) -> String:
49  +line = String.take(piece, Nat.sub(String.length(piece), 1n))
50  Bool.pick(
51    String,
52    String.ends_with(line, "\r"),
53    String.take(line, Nat.sub(String.length(line), 1n)),
54    line
55  )

Uses (6)

Used by (1)