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

Function pubsubFromOptions

packages/effect/src/internal/stream.ts:7046–7069  ·  view source on GitHub ↗
(
  options: number | {
    readonly capacity: "unbounded"
    readonly replay?: number | undefined
  } | {
    readonly capacity: number
    readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
    readonly replay?: number | undefined
  }
)

Source from the content-addressed store, hash-verified

7044)
7045
7046const pubsubFromOptions = <A, E>(
7047 options: number | {
7048 readonly capacity: "unbounded"
7049 readonly replay?: number | undefined
7050 } | {
7051 readonly capacity: number
7052 readonly strategy?: "sliding" | "dropping" | "suspend" | undefined
7053 readonly replay?: number | undefined
7054 }
7055): Effect.Effect<PubSub.PubSub<Take.Take<A, E>>> => {
7056 if (typeof options === "number") {
7057 return PubSub.bounded(options)
7058 } else if (options.capacity === "unbounded") {
7059 return PubSub.unbounded({ replay: options.replay })
7060 }
7061 switch (options.strategy) {
7062 case "dropping":
7063 return PubSub.dropping(options)
7064 case "sliding":
7065 return PubSub.sliding(options)
7066 default:
7067 return PubSub.bounded(options)
7068 }
7069}
7070
7071/** @internal */
7072export const toPubSub = dual<

Callers 1

stream.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected