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

Function start

packages/effect/src/Stream.ts:10944–10964  ·  view source on GitHub ↗
(controller)

Source from the content-addressed store, hash-verified

10942
10943 return new ReadableStream<A>({
10944 start(controller) {
10945 fiber = Effect.runFork(Effect.provideContext(
10946 runForEachArray(self, (chunk) =>
10947 latch.whenOpen(Effect.sync(() => {
10948 latch.closeUnsafe()
10949 for (let i = 0; i < chunk.length; i++) {
10950 controller.enqueue(chunk[i])
10951 }
10952 currentResolve!()
10953 currentResolve = undefined
10954 }))),
10955 context
10956 ))
10957 fiber.addObserver((exit) => {
10958 if (exit._tag === "Failure") {
10959 controller.error(Cause.squash(exit.cause))
10960 } else {
10961 controller.close()
10962 }
10963 })
10964 },
10965 pull() {
10966 return new Promise<void>((resolve) => {
10967 currentResolve = resolve

Callers

nothing calls this directly

Calls 6

whenOpenMethod · 0.80
addObserverMethod · 0.80
errorMethod · 0.80
closeUnsafeMethod · 0.65
closeMethod · 0.65
syncMethod · 0.45

Tested by

no test coverage detected