Changeset: Remove unused lastIndex() method from op iterator

This commit is contained in:
Richard Hansen 2021-10-20 19:15:30 -04:00
parent 0fd2a46783
commit dd8ec4e291
2 changed files with 2 additions and 10 deletions

View file

@ -39,7 +39,8 @@
* `readonly`: Deprecated; use the new `readOnly` property instead.
* `rev`: Deprecated.
* Changes to the `src/static/js/Changeset.js` library:
* `opIterator()`: The unused start index parameter has been removed.
* `opIterator()`: The unused start index parameter has been removed, as has
the unused `lastIndex()` method on the returned object.
### Notable enhancements

View file

@ -134,7 +134,6 @@ exports.newLen = (cs) => exports.unpack(cs).newLen;
*
* @typedef {object} OpIter
* @property {Function} hasNext -
* @property {Function} lastIndex -
* @property {Function} next -
*/
@ -146,14 +145,9 @@ exports.newLen = (cs) => exports.unpack(cs).newLen;
*/
exports.opIterator = (opsStr) => {
const regex = /((?:\*[0-9a-z]+)*)(?:\|([0-9a-z]+))?([-+=])([0-9a-z]+)|\?|/g;
let curIndex = 0;
let prevIndex = curIndex;
const nextRegexMatch = () => {
prevIndex = curIndex;
regex.lastIndex = curIndex;
const result = regex.exec(opsStr);
curIndex = regex.lastIndex;
if (result[0] === '?') {
exports.error('Hit error opcode in op stream');
}
@ -178,12 +172,9 @@ exports.opIterator = (opsStr) => {
const hasNext = () => !!(regexResult[0]);
const lastIndex = () => prevIndex;
return {
next,
hasNext,
lastIndex,
};
};