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

Function clear

packages/effect/src/Queue.ts:1276–1284  ·  view source on GitHub ↗
(self: Dequeue<A, E>)

Source from the content-addressed store, hash-verified

1274 * @since 4.0.0
1275 */
1276export const clear = <A, E>(self: Dequeue<A, E>): Effect<Array<A>, Pull.ExcludeDone<E>> =>
1277 suspendTake(() => {
1278 if (self.state._tag === "Done") {
1279 return Pull.catchDone(self.state.exit, () => internalEffect.succeed([]))
1280 }
1281 const messages = takeAllUnsafe(self)
1282 releaseCapacity(self)
1283 return internalEffect.succeed(messages)
1284 })
1285
1286/**
1287 * Takes all currently available messages, waiting until at least one message

Callers

nothing calls this directly

Calls 3

takeAllUnsafeFunction · 0.85
releaseCapacityFunction · 0.85
succeedMethod · 0.45

Tested by

no test coverage detected