UNPKG

@jaenster/channels

Version:

simple concurrency channel messaging

15 lines (14 loc) 509 B
import { EventTS } from '@jaenster/events'; import { FiFo } from '@jaenster/queues'; import type { ChannelClient } from "./client"; export interface Channel<T> { on<S = this>(this: S, on: 'data', cb: (this: S, data: T) => any, s?: object): any; in(...t: T[]): void; } export declare class Channel<T> extends EventTS { protected queue: FiFo<T>; constructor(); static factory<T>(this: { new (): Channel<[ChannelClient<T>, T]>; }): Channel<[ChannelClient<T>, T]>; }