Hyperlinkv0.8.0-beta.28

Stream

Stream.splitLinesconsteffect/Stream.ts:9459
<E, R>(self: Stream<string, E, R>): Stream<string, E, R>

Splits a stream of strings into lines, handling \n, \r, and \r\n delimiters across chunks.

Example (Splitting streamed text into lines)

import { Console, Effect, Stream } from "effect"

Effect.runPromise(Effect.gen(function* () {
  const lines = yield* Stream.runCollect(
    Stream.make("a\nb\r\n", "c\n").pipe(Stream.splitLines)
  )
  yield* Console.log(lines)
}))
// ["a", "b", "c"]
encoding
Source effect/Stream.ts:94595 lines
export const splitLines = <E, R>(self: Stream<string, E, R>): Stream<string, E, R> =>
  self.channel.pipe(
    Channel.pipeTo(Channel.splitLines()),
    fromChannel
  )