1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { countFirstChildren } from "https://esm.town/v/nbbaier/countFirstChildren";
import { countAllChildren } from "https://esm.town/v/nbbaier/countAllChildren";
import { filterFields } from "https://esm.town/v/nbbaier/filterFields";
export const countTanaNodes = (req: express.Request, res: express.Response) => {
const { type, node } = req.body;
const lines = filterFields(node);
console.log(lines, lines.length);
const root = lines[0].substring(2);
let count: number;
switch (type) {
case "all":
count = countAllChildren(lines);
res.send(String(count));
break;
case "first":
count = countFirstChildren(lines);
res.send(String(count));
break;
}
};