UNPKG

inngest

Version:

Official SDK for Inngest.com. Inngest is the reliability layer for modern applications. Inngest combines durable execution, events, and queues into a zero-infra platform with built-in observability.

31 lines (30 loc) 890 B
//#region src/components/realtime/subscribe/StreamFanout.ts var StreamFanout = class { #writers = /* @__PURE__ */ new Set(); createStream(transform) { const { readable, writable } = new TransformStream({ transform: (chunk, controller) => { controller.enqueue(transform ? transform(chunk) : chunk); } }); const writer = writable.getWriter(); this.#writers.add(writer); writer.closed.catch(() => {}).finally(() => { this.#writers.delete(writer); }); return readable; } write(chunk) { for (const writer of this.#writers) writer.ready.then(() => writer.write(chunk)).catch(() => this.#writers.delete(writer)); } close() { for (const writer of this.#writers) try { writer.close().catch(() => {}); } catch {} this.#writers.clear(); } size() { return this.#writers.size; } }; //#endregion export { StreamFanout }; //# sourceMappingURL=StreamFanout.js.map