MCPcopy Index your code
hub / github.com/Effect-TS/effect / unpackString

Function unpackString

packages/platform/src/Ndjson.ts:178–196  ·  view source on GitHub ↗
(options?: NdjsonOptions)

Source from the content-addressed store, hash-verified

176 * @category constructors
177 */
178export const unpackString = <IE = never, Done = unknown>(options?: NdjsonOptions): Channel.Channel<
179 Chunk.Chunk<unknown>,
180 Chunk.Chunk<string>,
181 IE | NdjsonError,
182 IE,
183 Done,
184 Done
185> => {
186 const lines = Channel.splitLines<IE, Done>().pipe(
187 options?.ignoreEmptyLines === true ?
188 Channel.pipeTo(filterEmptyChannel()) :
189 identity
190 )
191 return Channel.mapOutEffect(lines, (chunk) =>
192 Effect.try({
193 try: () => Chunk.map(chunk, (_) => JSON.parse(_)),
194 catch: (cause) => new NdjsonError({ reason: "Unpack", cause })
195 }))
196}
197
198const decodeString = <IE, Done>() => {
199 const decoder = new TextDecoder()

Callers 3

unpackFunction · 0.85
unpackSchemaStringFunction · 0.85
Ndjson.tsFile · 0.85

Calls 4

filterEmptyChannelFunction · 0.85
parseMethod · 0.80
pipeMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected