kotlinx-io icon indicating copy to clipboard operation
kotlinx-io copied to clipboard

Support predicated reading/copying

Open fzhinkin opened this issue 2 years ago • 0 comments
trafficstars

In some cases, it might be helpful to read from a source while a predicate is true instead of reading some fixed number of bytes.

One example is reading a line (Source.readLine/Source.readLineStrict) where the predicate is implicit. Another example of similar idea is Source.readWithSeparatorTo from dataforge-core project (https://github.com/SciProgCentre/dataforge-core/blob/a136db16ff9fb0de938d124ac0fe9f3408ccc030/dataforge-io/src/commonMain/kotlin/space/kscience/dataforge/io/ioMisc.kt#L121) where data from a source is copied into a sink until some multi-byte separator appears.

It seems worth supporting the reading with a predicate.

fzhinkin avatar Jul 18 '23 09:07 fzhinkin