MCPcopy Index your code
hub / github.com/Effect-TS/effect / writableOutput

Function writableOutput

packages/platform-node-shared/src/internal/sink.ts:41–57  ·  view source on GitHub ↗
(
  writable: Writable | NodeJS.WritableStream,
  deferred: Deferred.Deferred<void, IE | E>,
  onError: (error: unknown) => E
)

Source from the content-addressed store, hash-verified

39 )
40
41const writableOutput = <IE, E>(
42 writable: Writable | NodeJS.WritableStream,
43 deferred: Deferred.Deferred<void, IE | E>,
44 onError: (error: unknown) => E
45) =>
46 Effect.suspend(() => {
47 function handleError(err: unknown) {
48 Deferred.unsafeDone(deferred, Effect.fail(onError(err)))
49 }
50 writable.on("error", handleError)
51 return Effect.ensuring(
52 Deferred.await(deferred),
53 Effect.sync(() => {
54 writable.removeListener("error", handleError)
55 })
56 )
57 })

Callers 1

fromWritableChannelFunction · 0.85

Calls 2

syncMethod · 0.80
awaitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…