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

Function start

packages/effect/src/internal/stream.ts:7253–7276  ·  view source on GitHub ↗
(controller)

Source from the content-addressed store, hash-verified

7251
7252 return new ReadableStream<A>({
7253 start(controller) {
7254 fiber = runFork(runForEachChunk(self, (chunk) => {
7255 if (chunk.length === 0) return Effect.void
7256 return latch.whenOpen(Effect.sync(() => {
7257 latch.unsafeClose()
7258 for (const item of chunk) {
7259 controller.enqueue(item)
7260 }
7261 currentResolve!()
7262 currentResolve = undefined
7263 }))
7264 }))
7265 fiber.addObserver((exit) => {
7266 try {
7267 if (exit._tag === "Failure") {
7268 controller.error(Cause.squash(exit.cause))
7269 } else {
7270 controller.close()
7271 }
7272 } catch {
7273 // ignore
7274 }
7275 })
7276 },
7277 pull() {
7278 return new Promise<void>((resolve) => {
7279 currentResolve = resolve

Callers

nothing calls this directly

Calls 6

syncMethod · 0.80
unsafeCloseMethod · 0.80
runForkFunction · 0.70
addObserverMethod · 0.65
errorMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected