From 730b2022eb71ebfcf7ac5fc0ef4048a8c703cb9d Mon Sep 17 00:00:00 2001
From: Empress Sela <empresssela@cock.li>
Date: Fri, 17 Jul 2020 20:00:27 -0400
Subject: [PATCH] Typos & formatting

---
 src/js/ibcJS.js | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/js/ibcJS.js b/src/js/ibcJS.js
index a1ef28282ad..da8805f6e61 100644
--- a/src/js/ibcJS.js
+++ b/src/js/ibcJS.js
@@ -1,6 +1,9 @@
 globalThis.ibc = (() => {
     // These IDs are considered to be unknown parents
     let or_null = (s) => specificCharacterID(s) ? s : null;
+
+    // Find some sort of state for a slave. Checks first the gene pool, then V.slaves, then the
+    // missing table
     let find_gp = (id) => (V.genePool.find((s) => s.ID == id) || slaveStateById(id) || ((id in V.missingTable) ? V.missingTable[id] : null) || null);
 
     // Create a node for the given ID
@@ -8,10 +11,10 @@ globalThis.ibc = (() => {
         id: id, // Node ID
         mother: null,
         father: null,
-        nc: [], // NodeCodes
-        nc_s: [], // String version of the NodeCodes, for comparison
+        nodecodes: [], // NodeCodes
+        nodecodes_str: [], // String version of the NodeCodes, for comparison
         _coeff: null, // Cached CoI
-        cc: 0 // Number of children of the node, for computing NodeCodes
+        child_count: 0 // Number of children of the node, for computing NodeCodes
     });
 
     // Determine the length of the shared prefix between the two NodeCode parameters
@@ -28,16 +31,16 @@ globalThis.ibc = (() => {
     let prefixes = (a, b) => {
         let found = [];
         let found_s = [];
-        a.nc.forEach(nca => {
+        a.nodecodes.forEach(nca => {
             let match = false;
-            b.nc.forEach(ncb => {
+            b.nodecodes.forEach(ncb => {
                 let l = prefix_len(nca, ncb);
                 if (l === 0 && match) 
                     return;
 
                 if (l > 0) {
                     match = true;
-                    let pfx = nca.slice(0,l)
+                    let pfx = nca.slice(0,l);
                     let pfx_s = pfx.join(';');
 
                     if (!found_s.includes(pfx_s)) {
@@ -53,7 +56,7 @@ globalThis.ibc = (() => {
 
     // Search up the tree to find a given NodeCode, starting at `n`
     let find_nc = (nc, n) => {
-        if (n.nc_s.includes(nc.join(';'))) {
+        if (n.nodecodes_str.includes(nc.join(';'))) {
             return n;
         }
 
@@ -76,7 +79,7 @@ globalThis.ibc = (() => {
             let p = pfx.pop(0);
             let ret = find_nc(p, a);
 
-            ret.nc.forEach(nc => {
+            ret.nodecodes.forEach(nc => {
                 let i = pfx_s.indexOf(nc.join(';'));
                 if (i == -1)
                     return;
@@ -94,7 +97,7 @@ globalThis.ibc = (() => {
     // Determine the set of NodeCodes on `n` with prefix `x`
     let mps = (n, x) => {
         let x_s = x.join(';');
-        return n.nc.filter(nc => (nc.slice(0, x.length).join(';') === x_s));
+        return n.nodecodes.filter(nc => (nc.slice(0, x.length).join(';') === x_s));
     };
 
     // Compute the set of all paths to the parents of `n` with prefix `x`
@@ -138,7 +141,7 @@ globalThis.ibc = (() => {
                     let m_pp = [];
                     let f_pp = [];
 
-                    co.nc.forEach(nc => {
+                    co.nodecodes.forEach(nc => {
                         if (nc.slice(0, p.length).join(';') != p_s)
                             return;
 
@@ -210,7 +213,7 @@ globalThis.ibc = (() => {
         Object.values(nodes).forEach(n => {
             if (n.mother !== null || n.father !== null)
                 return;
-            n.nc.push([curid]);
+            n.nodecodes.push([curid]);
             curid += 1;
             seen.push(n.id);
         });
@@ -221,7 +224,7 @@ globalThis.ibc = (() => {
                 let n = nodes[s];
                 if (seen.includes(+s)) // We've already done this
                     return;
-                else if ((n.mother !== null && n.mother.nc.length === 0) || (n.father !== null && n.father.nc.length === 0)) // Too soon, we haven't done its parents
+                else if ((n.mother !== null && n.mother.nodecodes.length === 0) || (n.father !== null && n.father.nodecodes.length === 0)) // Too soon, we haven't done its parents
                     return;
 
                 seen.push(n.id);
@@ -230,23 +233,23 @@ globalThis.ibc = (() => {
                     if (a === null || (n.mother === n.father && i == 1)) // Ignore missing parents/repeated
                         return;
 
-                    a.nc.forEach(nc => {
+                    a.nodecodes.forEach(nc => {
                         // Copy the NodeCode, push the child number, then add it
                         let nnc = nc.slice();
-                        nnc.push(a.cc);
-                        n.nc.push(nnc);
+                        nnc.push(a.child_count);
+                        n.nodecodes.push(nnc);
                     });
-                    a.cc += 1;
+                    a.child_count += 1;
                 });
 
                 // NodeCodes must be sorted; this suffices
-                n.nc.sort()
+                n.nodecodes.sort()
             });
         }
 
         // Cache the string NodeCodes
         Object.values(nodes).forEach(n => {
-            n.nc_s = n.nc.map(nc => nc.join(';'));
+            n.nodecodes_str = n.nodecodes.map(nc => nc.join(';'));
         });
     };
 
-- 
GitLab