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

Function take

packages/effect/src/internal/stream/handoff.ts:139–163  ·  view source on GitHub ↗
(self: Handoff<A>)

Source from the content-addressed store, hash-verified

137
138/** @internal */
139export const take = <A>(self: Handoff<A>): Effect.Effect<A> =>
140 Effect.flatMap(Deferred.make<void>(), (deferred) =>
141 Effect.flatten(
142 Ref.modify(self.ref, (state) =>
143 pipe(
144 state,
145 handoffStateMatch(
146 (notifyConsumer) =>
147 [
148 Effect.flatMap(
149 Deferred.await(notifyConsumer),
150 () => take(self)
151 ),
152 state
153 ] as const,
154 (value, notifyProducer) => [
155 Effect.as(
156 Deferred.succeed(notifyProducer, void 0),
157 value
158 ),
159 handoffStateEmpty<A>(deferred)
160 ]
161 )
162 ))
163 ))
164
165/** @internal */
166export const poll = <A>(self: Handoff<A>): Effect.Effect<Option.Option<A>> =>

Callers

nothing calls this directly

Calls 6

handoffStateMatchFunction · 0.85
handoffStateEmptyFunction · 0.85
makeMethod · 0.65
modifyMethod · 0.65
pipeFunction · 0.50
awaitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…