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

Function packString

packages/platform/src/Ndjson.ts:69–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67 * @category constructors
68 */
69export const packString = <IE = never, Done = unknown>(): Channel.Channel<
70 Chunk.Chunk<string>,
71 Chunk.Chunk<unknown>,
72 IE | NdjsonError,
73 IE,
74 Done,
75 Done
76> => {
77 const loop: Channel.Channel<
78 Chunk.Chunk<string>,
79 Chunk.Chunk<unknown>,
80 IE | NdjsonError,
81 IE,
82 Done,
83 Done
84 > = Channel.readWithCause({
85 onInput: (input: Chunk.Chunk<unknown>) =>
86 Channel.zipRight(
87 Channel.flatMap(
88 Effect.try({
89 try: () => Chunk.of(Chunk.toReadonlyArray(input).map((_) => JSON.stringify(_)).join("\n") + "\n"),
90 catch: (cause) => new NdjsonError({ reason: "Pack", cause })
91 }),
92 Channel.write
93 ),
94 loop
95 ),
96 onFailure: Channel.failCause,
97 onDone: Channel.succeed
98 })
99 return loop
100}
101
102/**
103 * @since 1.0.0

Callers 3

packFunction · 0.85
packSchemaStringFunction · 0.85
Ndjson.tsFile · 0.85

Calls 3

ofMethod · 0.65
joinMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected