auto-cr-rules 2.0.35 → 2.0.36

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.
@@ -84,15 +84,16 @@ var readUtf8Character = function (source, index, code) {
84
84
  return { bytes: 3, nextIndex: index + 1 };
85
85
  };
86
86
  var bytePosToCharIndex = function (source, moduleStart, bytePos) {
87
- if (bytePos <= moduleStart) {
87
+ var target = Math.max(bytePos - moduleStart, 0);
88
+ if (target === 0) {
88
89
  return 0;
89
90
  }
90
91
  var index = 0;
91
- var byteOffset = moduleStart;
92
+ var byteOffset = 0;
92
93
  while (index < source.length) {
93
94
  var code = source.charCodeAt(index);
94
95
  var _a = readUtf8Character(source, index, code), bytes = _a.bytes, nextIndex = _a.nextIndex;
95
- if (byteOffset + bytes > bytePos) {
96
+ if (byteOffset + bytes > target) {
96
97
  return index;
97
98
  }
98
99
  byteOffset += bytes;
@@ -142,15 +142,16 @@ var readUtf8Character = function (source, index, code) {
142
142
  return { bytes: 3, nextIndex: index + 1 };
143
143
  };
144
144
  var bytePosToCharIndex = function (source, moduleStart, bytePos) {
145
- if (bytePos <= moduleStart) {
145
+ var target = Math.max(bytePos - moduleStart, 0);
146
+ if (target === 0) {
146
147
  return 0;
147
148
  }
148
149
  var index = 0;
149
- var byteOffset = moduleStart;
150
+ var byteOffset = 0;
150
151
  while (index < source.length) {
151
152
  var code = source.charCodeAt(index);
152
153
  var _a = readUtf8Character(source, index, code), bytes = _a.bytes, nextIndex = _a.nextIndex;
153
- if (byteOffset + bytes > bytePos) {
154
+ if (byteOffset + bytes > target) {
154
155
  return index;
155
156
  }
156
157
  byteOffset += bytes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-cr-rules",
3
- "version": "2.0.35",
3
+ "version": "2.0.36",
4
4
  "description": "Extensible static analysis rule set for the auto-cr automated code review toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",