Hyperlinkv0.8.0-beta.28

Channel

Channel.decodeTextconsteffect/Channel.ts:6446
<Err, Done>(encoding?: string, options?: TextDecoderOptions): Channel<
  Arr.NonEmptyReadonlyArray<string>,
  Err,
  Done,
  Arr.NonEmptyReadonlyArray<Uint8Array>,
  Err,
  Done
>

Decodes incoming Uint8Array chunks into strings using TextDecoder.

Details

Input chunks are decoded with streaming enabled so multi-byte characters may span Uint8Array boundaries. The optional encoding and options are passed to TextDecoder.

String manipulation
Source effect/Channel.ts:644615 lines
export const decodeText = <Err, Done>(encoding?: string, options?: TextDecoderOptions): Channel<
  Arr.NonEmptyReadonlyArray<string>,
  Err,
  Done,
  Arr.NonEmptyReadonlyArray<Uint8Array>,
  Err,
  Done
> =>
  fromTransform((upstream, _scope) =>
    Effect.sync(() => {
      const decoder = new TextDecoder(encoding, options)
      const streamOptions = { stream: true }
      return Effect.map(upstream, Arr.map((line) => decoder.decode(line, streamOptions)))
    })
  )