UNPKG

581 BJavaScriptView Raw
1export const NODE_TYPE_ROOT = Symbol("ROOT");
2export const NODE_TYPE_CHILD = Symbol("CHILD");
3export const createRootNode = () => {
4 return {
5 type: NODE_TYPE_ROOT,
6 children: new Map(),
7 };
8};
9export const createOrGetChild = (parent, label) => {
10 let child = parent.children.get(label);
11 if (child === undefined) {
12 child = {
13 type: NODE_TYPE_CHILD,
14 label,
15 children: new Map(),
16 parent,
17 };
18 parent.children.set(label, child);
19 }
20 return child;
21};
22//# sourceMappingURL=nodes.js.map
\No newline at end of file