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;
|
||||
|
||||
forEditorField([], (field) => {
|
||||
const matches = field.editingArea.editable.fieldHTML.matchAll(clozePattern);
|
||||
highest = Math.max(
|
||||
highest,
|
||||
...[...matches].map((match: RegExpMatchArray): number => Number(match[1]))
|
||||
);
|
||||
const fieldHTML = field.editingArea.editable.fieldHTML;
|
||||
const matches: number[] = [];
|
||||
let match: RegExpMatchArray | null = null;
|
||||
|
||||
while ((match = clozePattern.exec(fieldHTML))) {
|
||||
matches.push(Number(match[1]));
|
||||
}
|
||||
|
||||
highest = Math.max(highest, ...matches);
|
||||
});
|
||||
|
||||
if (increment) {
|
||||
|
@ -3,14 +3,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "es6",
|
||||
"lib": [
|
||||
"es2017",
|
||||
"es2020.string",
|
||||
"es2019.array",
|
||||
"es2018.promise",
|
||||
"dom",
|
||||
"dom.iterable"
|
||||
],
|
||||
"lib": ["es2017", "es2019.array", "es2018.promise", "dom", "dom.iterable"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"anki/*": ["../bazel-bin/ts/lib/*"],
|
||||
|
Loading…
Reference in New Issue
Block a user