UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

25 lines (24 loc) • 599 B
import { logger } from "../../utils/logger.js"; export class FrameBus { handlers = {}; subscribe(type, fn) { if (!this.handlers[type]) { this.handlers[type] = []; } this.handlers[type].push(fn); } publish(frame) { const subs = this.handlers[frame.type]; if (!subs) { return; } for (const fn of subs) { try { fn(frame); } catch (err) { logger.error(`[FrameBus] Subscriber threw on ${frame.type}:`, err); } } } }