clarity-pattern-parser 11.4.0 → 11.4.1

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
@@ -429,7 +429,7 @@ class CursorHistory {
429
429
 
430
430
  class Cursor {
431
431
  get text() {
432
- return this._text;
432
+ return this._chars.join("");
433
433
  }
434
434
  get isOnFirst() {
435
435
  return this._index === 0;
@@ -477,12 +477,12 @@ class Cursor {
477
477
  return this._history.error != null;
478
478
  }
479
479
  get currentChar() {
480
- return this._text[this._index];
480
+ return this._chars[this._index];
481
481
  }
482
482
  constructor(text) {
483
- this._text = text;
483
+ this._chars = [...text];
484
484
  this._index = 0;
485
- this._length = [...text].length;
485
+ this._length = this._chars.length;
486
486
  this._history = new CursorHistory();
487
487
  }
488
488
  hasNext() {
@@ -516,7 +516,7 @@ class Cursor {
516
516
  return this._length - 1;
517
517
  }
518
518
  getChars(first, last) {
519
- return this._text.slice(first, last + 1);
519
+ return this._chars.slice(first, last + 1).join("");
520
520
  }
521
521
  recordMatch(pattern, node) {
522
522
  this._history.recordMatch(pattern, node);
@@ -765,7 +765,9 @@ class Regex {
765
765
  }
766
766
  processResult(cursor, result) {
767
767
  const currentIndex = cursor.index;
768
- const newIndex = currentIndex + result[0].length - 1;
768
+ const match = result[0];
769
+ const matchLength = [...match].length;
770
+ const newIndex = currentIndex + matchLength - 1;
769
771
  this._node = new Node("regex", this._name, currentIndex, newIndex, undefined, result[0]);
770
772
  cursor.moveTo(newIndex);
771
773
  cursor.recordMatch(this, this._node);