Skip to content

Commit dd8ec4e

Browse files
committed
Changeset: Remove unused lastIndex() method from op iterator
1 parent 0fd2a46 commit dd8ec4e

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
* `readonly`: Deprecated; use the new `readOnly` property instead.
4040
* `rev`: Deprecated.
4141
* Changes to the `src/static/js/Changeset.js` library:
42-
* `opIterator()`: The unused start index parameter has been removed.
42+
* `opIterator()`: The unused start index parameter has been removed, as has
43+
the unused `lastIndex()` method on the returned object.
4344

4445
### Notable enhancements
4546

src/static/js/Changeset.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ exports.newLen = (cs) => exports.unpack(cs).newLen;
134134
*
135135
* @typedef {object} OpIter
136136
* @property {Function} hasNext -
137-
* @property {Function} lastIndex -
138137
* @property {Function} next -
139138
*/
140139

@@ -146,14 +145,9 @@ exports.newLen = (cs) => exports.unpack(cs).newLen;
146145
*/
147146
exports.opIterator = (opsStr) => {
148147
const regex = /((?:\*[0-9a-z]+)*)(?:\|([0-9a-z]+))?([-+=])([0-9a-z]+)|\?|/g;
149-
let curIndex = 0;
150-
let prevIndex = curIndex;
151148

152149
const nextRegexMatch = () => {
153-
prevIndex = curIndex;
154-
regex.lastIndex = curIndex;
155150
const result = regex.exec(opsStr);
156-
curIndex = regex.lastIndex;
157151
if (result[0] === '?') {
158152
exports.error('Hit error opcode in op stream');
159153
}
@@ -178,12 +172,9 @@ exports.opIterator = (opsStr) => {
178172

179173
const hasNext = () => !!(regexResult[0]);
180174

181-
const lastIndex = () => prevIndex;
182-
183175
return {
184176
next,
185177
hasNext,
186-
lastIndex,
187178
};
188179
};
189180

0 commit comments

Comments
 (0)