UNPKG

@tanstack/db-ivm

Version:

Incremental View Maintenance for TanStack DB based on Differential Dataflow

47 lines (46 loc) 1.76 kB
"use strict"; var __typeError = (msg) => { throw TypeError(msg); }; var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); var _fn; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const graph = require("../graph.cjs"); const d2 = require("../d2.cjs"); class OutputOperator extends graph.UnaryOperator { constructor(id, inputA, outputWriter, fn) { super(id, inputA, outputWriter); __privateAdd(this, _fn); __privateSet(this, _fn, fn); } run() { for (const message of this.inputMessages()) { __privateGet(this, _fn).call(this, message); this.output.sendData(message); } } } _fn = new WeakMap(); function output(fn) { return (stream) => { const outputStream = new d2.StreamBuilder( stream.graph, new graph.DifferenceStreamWriter() ); const operator = new OutputOperator( stream.graph.getNextOperatorId(), stream.connectReader(), outputStream.writer, fn ); stream.graph.addOperator(operator); stream.graph.addStream(outputStream.connectReader()); return outputStream; }; } exports.OutputOperator = OutputOperator; exports.output = output; //# sourceMappingURL=output.cjs.map