@electric-sql/d2mini
Version:
D2Mini is a minimal implementation of Differential Dataflow for performing in-memory incremental view maintenance.
24 lines • 825 B
JavaScript
import { DifferenceStreamWriter } from '../graph.js';
import { StreamBuilder } from '../d2.js';
import { LinearUnaryOperator } from '../graph.js';
/**
* Operator that negates the multiplicities in the input stream
*/
export class NegateOperator extends LinearUnaryOperator {
inner(collection) {
return collection.negate();
}
}
/**
* Negates the multiplicities in the input stream
*/
export function negate() {
return (stream) => {
const output = new StreamBuilder(stream.graph, new DifferenceStreamWriter());
const operator = new NegateOperator(stream.graph.getNextOperatorId(), stream.connectReader(), output.writer);
stream.graph.addOperator(operator);
stream.graph.addStream(output.connectReader());
return output;
};
}
//# sourceMappingURL=negate.js.map