mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
Changeset: Remove unused lastIndex()
method from op iterator
This commit is contained in:
parent
0fd2a46783
commit
dd8ec4e291
2 changed files with 2 additions and 10 deletions
|
@ -39,7 +39,8 @@
|
||||||
* `readonly`: Deprecated; use the new `readOnly` property instead.
|
* `readonly`: Deprecated; use the new `readOnly` property instead.
|
||||||
* `rev`: Deprecated.
|
* `rev`: Deprecated.
|
||||||
* Changes to the `src/static/js/Changeset.js` library:
|
* 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
|
### Notable enhancements
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,6 @@ exports.newLen = (cs) => exports.unpack(cs).newLen;
|
||||||
*
|
*
|
||||||
* @typedef {object} OpIter
|
* @typedef {object} OpIter
|
||||||
* @property {Function} hasNext -
|
* @property {Function} hasNext -
|
||||||
* @property {Function} lastIndex -
|
|
||||||
* @property {Function} next -
|
* @property {Function} next -
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -146,14 +145,9 @@ exports.newLen = (cs) => exports.unpack(cs).newLen;
|
||||||
*/
|
*/
|
||||||
exports.opIterator = (opsStr) => {
|
exports.opIterator = (opsStr) => {
|
||||||
const regex = /((?:\*[0-9a-z]+)*)(?:\|([0-9a-z]+))?([-+=])([0-9a-z]+)|\?|/g;
|
const regex = /((?:\*[0-9a-z]+)*)(?:\|([0-9a-z]+))?([-+=])([0-9a-z]+)|\?|/g;
|
||||||
let curIndex = 0;
|
|
||||||
let prevIndex = curIndex;
|
|
||||||
|
|
||||||
const nextRegexMatch = () => {
|
const nextRegexMatch = () => {
|
||||||
prevIndex = curIndex;
|
|
||||||
regex.lastIndex = curIndex;
|
|
||||||
const result = regex.exec(opsStr);
|
const result = regex.exec(opsStr);
|
||||||
curIndex = regex.lastIndex;
|
|
||||||
if (result[0] === '?') {
|
if (result[0] === '?') {
|
||||||
exports.error('Hit error opcode in op stream');
|
exports.error('Hit error opcode in op stream');
|
||||||
}
|
}
|
||||||
|
@ -178,12 +172,9 @@ exports.opIterator = (opsStr) => {
|
||||||
|
|
||||||
const hasNext = () => !!(regexResult[0]);
|
const hasNext = () => !!(regexResult[0]);
|
||||||
|
|
||||||
const lastIndex = () => prevIndex;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
next,
|
next,
|
||||||
hasNext,
|
hasNext,
|
||||||
lastIndex,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue