diff --git a/src/js/ibcJS.js b/src/js/ibcJS.js index 7d82694b237d6a2e26bc43acce03b58e1daec54b..98b950302065c0bdb73b6ab7e7197a7b44a6d5d2 100644 --- a/src/js/ibcJS.js +++ b/src/js/ibcJS.js @@ -69,7 +69,7 @@ globalThis.ibc = (() => { class CoancestryCache { - #valuesByLeastParentId = {}; + valuesByLeastParentId = {}; coefficientOfInbreeding(node) { if (node._coeff === null) @@ -85,7 +85,7 @@ globalThis.ibc = (() => { // just two simple rules are needed to express it: self-with-self coancestry is (1 + coefficient of inbreeding of self) / 2, and... return (1 + this.coefficientOfInbreeding(motherNode)) / 2; - return this.#kinship(motherNode.id, fatherNode.id, + return this.kinshipCache(motherNode.id, fatherNode.id, () => { let p1 = motherNode; let p2 = fatherNode; @@ -105,12 +105,12 @@ globalThis.ibc = (() => { }); } - #kinship(motherId, fatherId, calculateValue) { // this method exists solely for caching purposes + kinshipCache(motherId, fatherId, calculateValue) { // this method exists solely for caching purposes let id1 = motherId; let id2 = fatherId; if (id1 > id2) { let id_ = id1; id1 = id2; id2 = id_; } - let vs = this.#valuesByLeastParentId; + let vs = this.valuesByLeastParentId; let vs1 = vs[id1]; if (vs1 === undefined) @@ -118,10 +118,10 @@ globalThis.ibc = (() => { // cache format, conceptually: a set of arrays of numbers. the top-level set is indexed by id1. a lower-level array has the format // [id, kinship value, id, kinship value, ...] with the id in an entry corresponding to id2 here and with the pairs in the array being kept invariably sorted by id. - return this.#kinship_(vs1, id2, calculateValue); + return this.kinship_cache(vs1, id2, calculateValue); } - #kinship_(vs, id, calculateValue) { // this method exists solely for caching purposes + kinship_cache(vs, id, calculateValue) { // this method exists solely for caching purposes let entryCount = vs.length / 2; // do a simple binary search @@ -418,16 +418,16 @@ globalThis.ibc = (() => { class MockWorld { - #slaves; + slavesArray; constructor(matings) { - this.#slaves = []; + this.slavesArray = []; let slavesById = {}; let meetSlave = (id) => { if (!slavesById[id]) { let slave = new MockSlave(id); - this.#slaves.push(slave); + this.slavesArray.push(slave); slavesById[id] = slave; } @@ -446,7 +446,7 @@ globalThis.ibc = (() => { } findSlaveState(id) { - return this.#slaves.find(slave => slave.ID === id) || null; + return this.slavesArray.find(slave => slave.ID === id) || null; } }