From dd8ec4e291188c48448021d651508d3fe3ee3466 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 20 Oct 2021 19:15:30 -0400 Subject: [PATCH] Changeset: Remove unused `lastIndex()` method from op iterator --- CHANGELOG.md | 3 ++- src/static/js/Changeset.js | 9 --------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da1fb2068..450a2d8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/static/js/Changeset.js b/src/static/js/Changeset.js index 796ae9130..0d3d9991c 100644 --- a/src/static/js/Changeset.js +++ b/src/static/js/Changeset.js @@ -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, }; };