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

Function filterEmptyChannel

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

Source from the content-addressed store, hash-verified

148
149const filterEmpty = Chunk.filter<string>((line) => line.length > 0)
150const filterEmptyChannel = <IE, Done>() => {
151 const loop: Channel.Channel<
152 Chunk.Chunk<string>,
153 Chunk.Chunk<string>,
154 IE,
155 IE,
156 Done,
157 Done,
158 never
159 > = Channel.readWithCause({
160 onInput(input: Chunk.Chunk<string>) {
161 const filtered = filterEmpty(input)
162 return Channel.zipRight(Chunk.isEmpty(filtered) ? Channel.void : Channel.write(filtered), loop)
163 },
164 onFailure(cause: Cause.Cause<IE>) {
165 return Channel.failCause(cause)
166 },
167 onDone(done: Done) {
168 return Channel.succeed(done)
169 }
170 })
171 return loop
172}
173
174/**
175 * @since 1.0.0

Callers 1

unpackStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected