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

Method freeze

packages/effect/src/TestClock.ts:256–274  ·  view source on GitHub ↗

* Captures a "snapshot" of the identifier and status of all fibers in this * test other than the current fiber. Fails with the `void` value if any of * these fibers are not done or suspended. Note that because we cannot * synchronize on the status of multiple fibers at the same time this

()

Source from the content-addressed store, hash-verified

254 * snapshot may not be fully consistent.
255 */
256 freeze(): Effect.Effect<HashMap.HashMap<FiberId.FiberId, FiberStatus.FiberStatus>, void> {
257 return core.flatMap(this.supervisedFibers(), (fibers) =>
258 pipe(
259 fibers,
260 effect.reduce(HashMap.empty<FiberId.FiberId, FiberStatus.FiberStatus>(), (map, fiber) =>
261 pipe(
262 fiber.status,
263 core.flatMap((status) => {
264 if (FiberStatus.isDone(status)) {
265 return core.succeed(HashMap.set(map, fiber.id() as FiberId.FiberId, status as FiberStatus.FiberStatus))
266 }
267 if (FiberStatus.isSuspended(status)) {
268 return core.succeed(HashMap.set(map, fiber.id() as FiberId.FiberId, status as FiberStatus.FiberStatus))
269 }
270 return core.fail(void 0)
271 })
272 ))
273 ))
274 }
275 /**
276 * Forks a fiber that will display a warning message if a test is using time
277 * but is not advancing the `TestClock`.

Callers 1

suspendedMethod · 0.95

Calls 5

supervisedFibersMethod · 0.95
pipeFunction · 0.70
setMethod · 0.65
idMethod · 0.65
failMethod · 0.65

Tested by

no test coverage detected