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

Function consumer

packages/effect/src/internal/stream.ts:1164–1181  ·  view source on GitHub ↗
(
    queue: Queue.Queue<readonly [Take.Take<A, E>, Deferred.Deferred<void>]>
  )

Source from the content-addressed store, hash-verified

1162 })
1163 }
1164 const consumer = (
1165 queue: Queue.Queue<readonly [Take.Take<A, E>, Deferred.Deferred<void>]>
1166 ): Channel.Channel<Chunk.Chunk<A>, unknown, E, unknown, void, unknown, R> => {
1167 const process: Channel.Channel<Chunk.Chunk<A>, unknown, E, unknown, void, unknown> = pipe(
1168 core.fromEffect(Queue.take(queue)),
1169 core.flatMap(([take, deferred]) =>
1170 channel.zipRight(
1171 core.fromEffect(Deferred.succeed(deferred, void 0)),
1172 InternalTake.match(take, {
1173 onEnd: () => core.void,
1174 onFailure: core.failCause,
1175 onSuccess: (value) => pipe(core.write(value), core.flatMap(() => process))
1176 })
1177 )
1178 )
1179 )
1180 return process
1181 }
1182 return channel.unwrapScoped(
1183 pipe(
1184 scoped,

Callers 3

bufferSignalFunction · 0.85
enqueueFunction · 0.85
stream.tsFile · 0.85

Calls 10

enqueueFunction · 0.85
fromEffectMethod · 0.80
failCauseMethod · 0.80
pipeFunction · 0.70
takeMethod · 0.65
writeMethod · 0.65
pipeMethod · 0.65
mapMethod · 0.65
joinMethod · 0.65
interruptMethod · 0.45

Tested by

no test coverage detected