Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ZIO change stream framing. Example : delimit by lines
import zio._
import zio.stream._
import zio.console._
val streamIn = Stream.fromIterable(Set("first line\nsecond line\nthird ", "line"))
// or ZSink.splitDelimiter("\n")
val streamOut = streamIn.transduce(ZSink.splitLines).flatMap(chunk => Stream.fromChunk(chunk))
val runtime = new DefaultRuntime {}
runtime.unsafeRun(streamOut.map(_.replaceAll("\n","")).foreach(i => putStrLn(i)))
//output :
//first line
//second line
//third line
@cilicio

This comment has been minimized.

Copy link

@cilicio cilicio commented May 2, 2020

Sa

@cilicio

This comment has been minimized.

Copy link

@cilicio cilicio commented May 2, 2020

Us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment