mahler
Version:
A automated task composer and HTN based planner for building autonomous system agents
27 lines • 787 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyPatch = applyPatch;
exports.patch = patch;
const ref_1 = require("../ref");
const view_1 = require("../view");
function applyPatch(r, changes) {
changes = Array.isArray(changes) ? changes : [changes];
changes.forEach((change) => {
const view = view_1.View.from(r, change.path);
switch (change.op) {
case 'create':
case 'update':
view._ = change.target;
break;
case 'delete':
view.delete();
break;
}
});
}
function patch(s, changes) {
const r = ref_1.Ref.of(structuredClone(s));
applyPatch(r, changes);
return r._;
}
//# sourceMappingURL=patch.js.map