1'use strict'; 2 3class Edge { 4 constructor(filter, node, parent, parentKey) { 5 this.filter = filter; 6 this.node = node; 7 this.parent = parent; 8 this.parentKey = parentKey; 9 } 10} 11 12class Node { 13 constructor(data) { 14 this.data = data; 15 this.branches = null; 16 } 17 18 _ensureBranches() { 19 if (!this.branches) { 20 this.branches = Object.create(null); 21 } 22 } 23 24 addEdge(key, filter, node) { 25 this._ensureBranches(); 26 27 this.branches[key] = new Edge(filter, node, this, key); 28 } 29 30 addNode(key, node) { 31 this._ensureBranches(); 32 33 this.branches[key] = node; 34 } 35} 36 37module.exports = Node; 38