tarsec 0.1.7 → 0.1.8

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.
@@ -874,7 +874,7 @@ export function parseError(_message, ...parsers) {
874
874
  const inputStr = getInputStr();
875
875
  const messages = [];
876
876
  const prefix = "Near: ";
877
- if (input.length > 0) {
877
+ if (inputStr.length > 0) {
878
878
  const index = inputStr.length - input.length;
879
879
  const start = Math.max(0, index - 20);
880
880
  const end = Math.min(inputStr.length, index + 20);
@@ -886,11 +886,12 @@ export function parseError(_message, ...parsers) {
886
886
  const lines = inputStr.split("\n");
887
887
  let acc = 0;
888
888
  let i = 0;
889
- while (index > acc) {
889
+ while (index >= acc) {
890
890
  acc += lines[i].length;
891
891
  i++;
892
892
  }
893
- const column = lines[i - 1].length - (acc - index);
893
+ const linesIndex = Math.max(0, i - 1);
894
+ const column = lines[linesIndex].length - (acc - index);
894
895
  throw new TarsecError({
895
896
  line: i - 1,
896
897
  column,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tarsec",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "A parser combinator library for TypeScript, inspired by Parsec.",
5
5
  "homepage": "https://github.com/egonSchiele/tarsec",
6
6
  "scripts": {