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

Function parseLine

packages/effect/src/encoding/Ndjson.ts:233–245  ·  view source on GitHub ↗
(
  line: string,
  out: Array<unknown>,
  ignoreEmptyLines: boolean,
  unterminated: boolean
)

Source from the content-addressed store, hash-verified

231}
232
233const parseLine = (
234 line: string,
235 out: Array<unknown>,
236 ignoreEmptyLines: boolean,
237 unterminated: boolean
238): NdjsonError | undefined => {
239 if (ignoreEmptyLines && /^[ \t]*$/.test(line)) return
240 try {
241 out.push(JSON.parse(line))
242 } catch (cause) {
243 return new NdjsonError({ kind: "Unpack", reason: "InvalidJson", unterminated, cause })
244 }
245}
246
247const flushNothing = () => undefined
248

Callers 2

decodeStringFunction · 0.70
decodeLineFunction · 0.70

Calls 2

pushMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected