@lightningkite/ktor-batteries
Version:
53 lines • 2.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.xCollectionChangesMap = exports.xListApply = exports.CollectionChanges = void 0;
// Package: com.lightningkite.ktordb
// Generated by Khrysalis - this file will be overwritten.
const EntryChange_1 = require("./EntryChange");
const khrysalis_runtime_1 = require("@lightningkite/khrysalis-runtime");
//! Declares com.lightningkite.ktordb.CollectionChanges
class CollectionChanges {
constructor(changes = [], replace = null) {
this.changes = changes;
this.replace = replace;
}
static propertyTypes(T) { return { changes: [Array, [EntryChange_1.EntryChange, T]], replace: [Array, T] }; }
static pair(old = null, _new = null) {
let result = new CollectionChanges(old !== null || _new !== null ? [new EntryChange_1.EntryChange(old, _new)] : [], undefined);
return result;
}
}
exports.CollectionChanges = CollectionChanges;
CollectionChanges.properties = ["changes", "replace"];
(0, khrysalis_runtime_1.setUpDataClass)(CollectionChanges);
//! Declares com.lightningkite.ktordb.apply>kotlin.collections.Listcom.lightningkite.ktordb.apply.T
function xListApply(this_, changes) {
if (changes.replace !== null) {
return changes.replace;
}
const changeable = Array.from(this_);
for (const change of changes.changes) {
const old_0 = change.old;
if (old_0 !== null) {
(0, khrysalis_runtime_1.listRemoveAll)(changeable, (it) => ((0, khrysalis_runtime_1.safeEq)(it._id, old_0._id)));
}
const new_2 = change._new;
if (new_2 !== null) {
changeable.push(new_2);
}
}
return changeable;
}
exports.xListApply = xListApply;
//! Declares com.lightningkite.ktordb.map>com.lightningkite.ktordb.CollectionChangescom.lightningkite.ktordb.map.T
function xCollectionChangesMap(this_, mapper) {
return new CollectionChanges(this_.changes.map((it) => ((0, EntryChange_1.xEntryChangeMap)(it, mapper))), (() => {
const temp5 = this_.replace;
if (temp5 === null) {
return null;
}
return temp5.map(mapper);
})());
}
exports.xCollectionChangesMap = xCollectionChangesMap;
//# sourceMappingURL=CollectionChanges.js.map