MCPcopy
hub / github.com/Effect-TS/effect / concurrentFib

Function concurrentFib

packages/effect/test/Effect/concurrency.test.ts:23–34  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

21}
22
23const concurrentFib = (n: number): Effect.Effect<number> => {
24 if (n <= 1) {
25 return Effect.succeed(n)
26 }
27 return Effect.gen(function*() {
28 const fiber1 = yield* (Effect.fork(concurrentFib(n - 1)))
29 const fiber2 = yield* (Effect.fork(concurrentFib(n - 2)))
30 const v1 = yield* (Fiber.join(fiber1))
31 const v2 = yield* (Fiber.join(fiber2))
32 return v1 + v2
33 })
34}
35
36describe("Effect", () => {
37 it.effect("shallow fork/join identity", () =>

Callers 1

Calls 2

forkMethod · 0.65
joinMethod · 0.65

Tested by

no test coverage detected