UNPKG

@thi.ng/rstream

Version:

Reactive streams & subscription primitives for constructing dataflow graphs / pipelines

12 lines (11 loc) 319 B
import { __nextID } from "./idgen.js"; import { PubSub } from "./pubsub.js"; const bisect = (pred, truthy, falsy) => { const sub = new PubSub({ topic: pred, id: `bisect-${__nextID()}` }); truthy && sub.subscribeTopic(true, truthy); falsy && sub.subscribeTopic(false, falsy); return sub; }; export { bisect };