MCPcopy Create free account
hub / github.com/Effect-TS/effect / decodeLine

Function decodeLine

packages/effect/src/encoding/Ndjson.ts:372–384  ·  view source on GitHub ↗
(bytes: Uint8Array, out: Array<unknown>, unterminated: boolean)

Source from the content-addressed store, hash-verified

370 }
371
372 const decodeLine = (bytes: Uint8Array, out: Array<unknown>, unterminated: boolean) => {
373 let line: string
374 try {
375 line = decoder.decode(bytes)
376 } catch (cause) {
377 return new NdjsonError({ kind: "Unpack", reason: "InvalidUtf8", unterminated, cause })
378 }
379 const firstLine = decoder !== utf8Decoder
380 decoder = utf8Decoder
381 // A stripped BOM alone is not an unterminated record.
382 if (firstLine && unterminated && line.length === 0) return
383 return parseLine(line, out, ignoreEmptyLines, unterminated)
384 }
385
386 const step: DecodeStep<Arr.NonEmptyReadonlyArray<Uint8Array>> = (chunks, out) => {
387 for (const chunk of chunks) {

Callers 2

stepFunction · 0.85
flushFunction · 0.85

Calls 2

parseLineFunction · 0.70
decodeMethod · 0.45

Tested by

no test coverage detected