UNPKG

@electric-sql/d2mini

Version:

D2Mini is a minimal implementation of Differential Dataflow for performing in-memory incremental view maintenance.

33 lines 1.16 kB
import { DifferenceStreamWriter } from '../graph.js'; import { StreamBuilder } from '../d2.js'; import { BinaryOperator } from '../graph.js'; /** * Operator that concatenates two input streams */ export class ConcatOperator extends BinaryOperator { run() { for (const message of this.inputAMessages()) { this.output.sendData(message); } for (const message of this.inputBMessages()) { this.output.sendData(message); } } } /** * Concatenates two input streams * @param other - The other stream to concatenate */ export function concat(other) { return (stream) => { if (stream.graph !== other.graph) { throw new Error('Cannot concat streams from different graphs'); } const output = new StreamBuilder(stream.graph, new DifferenceStreamWriter()); const operator = new ConcatOperator(stream.graph.getNextOperatorId(), stream.connectReader(), other.connectReader(), output.writer); stream.graph.addOperator(operator); stream.graph.addStream(output.connectReader()); return output; }; } //# sourceMappingURL=concat.js.map