Prefer exec over matchAll
This commit is contained in:
parent
72b33bf361
commit
64db04f1bb
@ -17,11 +17,15 @@ function getCurrentHighestCloze(increment: boolean): number {
|
|||||||
let highest = 0;
|
let highest = 0;
|
||||||
|
|
||||||
forEditorField([], (field) => {
|
forEditorField([], (field) => {
|
||||||
const matches = field.editingArea.editable.fieldHTML.matchAll(clozePattern);
|
const fieldHTML = field.editingArea.editable.fieldHTML;
|
||||||
highest = Math.max(
|
const matches: number[] = [];
|
||||||
highest,
|
let match: RegExpMatchArray | null = null;
|
||||||
...[...matches].map((match: RegExpMatchArray): number => Number(match[1]))
|
|
||||||
);
|
while ((match = clozePattern.exec(fieldHTML))) {
|
||||||
|
matches.push(Number(match[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
highest = Math.max(highest, ...matches);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (increment) {
|
if (increment) {
|
||||||
|
@ -3,14 +3,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"module": "es6",
|
"module": "es6",
|
||||||
"lib": [
|
"lib": ["es2017", "es2019.array", "es2018.promise", "dom", "dom.iterable"],
|
||||||
"es2017",
|
|
||||||
"es2020.string",
|
|
||||||
"es2019.array",
|
|
||||||
"es2018.promise",
|
|
||||||
"dom",
|
|
||||||
"dom.iterable"
|
|
||||||
],
|
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"anki/*": ["../bazel-bin/ts/lib/*"],
|
"anki/*": ["../bazel-bin/ts/lib/*"],
|
||||||
|
Loading…
Reference in New Issue
Block a user