clarity-pattern-parser 10.2.11 → 10.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -199,11 +199,17 @@ class Node {
199
199
  }
200
200
  normalize(startIndex = this._firstIndex) {
201
201
  let length = 0;
202
+ let runningOffset = startIndex;
202
203
  if (this.children.length === 0) {
203
204
  length = this._value.length;
204
205
  }
205
206
  else {
206
- length = this.children.reduce((acc, c) => acc + c.normalize(acc + startIndex), startIndex) - startIndex;
207
+ for (let x = 0; x < this.children.length; x++) {
208
+ const child = this.children[x];
209
+ const childLength = child.normalize(runningOffset);
210
+ runningOffset += childLength;
211
+ length += childLength;
212
+ }
207
213
  }
208
214
  this._firstIndex = startIndex;
209
215
  this._lastIndex = Math.max(startIndex + length - 1, 0);
@@ -2941,7 +2947,7 @@ class ExpressionPattern {
2941
2947
  }
2942
2948
  else if (lastBinaryNode != null && lastUnaryNode != null && delimiterNode != null) {
2943
2949
  const precedence = this._precedenceMap[name];
2944
- const lastPrecendece = lastBinaryNode == null ? 0 : this._precedenceMap[lastBinaryNode.name] || -1;
2950
+ const lastPrecendece = lastBinaryNode == null ? 0 : this._precedenceMap[lastBinaryNode.name] == null ? -1 : this._precedenceMap[lastBinaryNode.name];
2945
2951
  const association = this._binaryAssociation[i];
2946
2952
  if (precedence === lastPrecendece && association === Association.right) {
2947
2953
  const node = createNode(name, [lastUnaryNode, delimiterNode]);