(node, index, useNewValue, valueHandler)
| 118 | } |
| 119 | |
| 120 | _createBranch(node, index, useNewValue, valueHandler) { |
| 121 | const newBranch = new Node(node.key.slice(index), node.value, node.edges); |
| 122 | node.key = node.key.slice(0, index); |
| 123 | node.edges = [ newBranch ]; |
| 124 | if (useNewValue) { |
| 125 | // The previous node value has moved to a leaf |
| 126 | // The node containing the new leaf should use the new value |
| 127 | node.value = valueHandler(); |
| 128 | this._onItemAdded(); |
| 129 | } |
| 130 | else { |
| 131 | // Clear the value as it was copied in the branch |
| 132 | node.value = null; |
| 133 | } |
| 134 | return newBranch; |
| 135 | } |
| 136 | |
| 137 | _onItemAdded() { |
| 138 | this.length++; |
no test coverage detected