Prefer exec over matchAll

This commit is contained in:
Henrik Giesel 2021-04-21 14:18:44 +02:00
parent 72b33bf361
commit 64db04f1bb
2 changed files with 10 additions and 13 deletions

View File

@ -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) {

View File

@ -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/*"],