MCPcopy Create free account
hub / github.com/cloudflare/computer / transform

Function transform

packages/computer/src/runtime/runtime.ts:393–407  ·  view source on GitHub ↗
(event, controller)

Source from the content-addressed store, hash-verified

391 return source.pipeThrough(
392 new TransformStream<WorkspaceRuntimeEvent, WorkspaceRuntimeEvent<E>>({
393 transform(event, controller) {
394 if (event.name === "stdout" || event.name === "stderr") {
395 if (event.name === "stdout") stdoutMeta = { id: event.id, seq: event.seq };
396 else stderrMeta = { id: event.id, seq: event.seq };
397 enqueue(controller, {
398 ...event,
399 value: (event.name === "stdout" ? stdoutDecoder : stderrDecoder).decode(event.value, {
400 stream: true,
401 }),
402 } as WorkspaceRuntimeEvent<E>);
403 } else {
404 if (event.name === "exit") flushPending(controller, event.seq);
405 enqueue(controller, event as WorkspaceRuntimeEvent<E>);
406 }
407 },
408 flush: flushPending,
409 }),
410 );

Callers

nothing calls this directly

Calls 2

enqueueFunction · 0.70
flushPendingFunction · 0.70

Tested by

no test coverage detected