Files
app-organization-portal/lib/delta.js
Claire Lovisa 3de5d8f184 Initial commit
2023-10-02 15:01:41 +02:00

29 lines
580 B
JavaScript

import { flatten } from 'lodash';
export class Delta {
constructor(delta) {
this.delta = delta;
}
get inserts() {
return flatten(this.delta.map(changeSet => changeSet.inserts));
}
get deletes() {
return flatten(this.delta.map(changeSet => changeSet.deletes));
}
getInsertsFor(predicate) {
return this.inserts
.filter(t => t.predicate.value === predicate)
.map(t => t.subject.value);
}
getDeletesFor(predicate) {
return this.deletes
.filter(t => t.predicate.value === predicate)
.map(t => t.subject.value);
}
}