fix: normalize anki deck sample size

This commit is contained in:
2026-05-17 19:18:12 -07:00
parent 10d9c38037
commit b076e8800f
2 changed files with 37 additions and 1 deletions
+7 -1
View File
@@ -187,7 +187,13 @@ export class AnkiConnectClient {
return [];
}
return this.notesInfo(noteIds.slice(0, sampleSize));
const finiteSampleSize = Number.isFinite(sampleSize) ? sampleSize : 0;
const normalizedSampleSize = Math.min(noteIds.length, Math.max(0, Math.floor(finiteSampleSize)));
if (normalizedSampleSize === 0) {
return [];
}
return this.notesInfo(noteIds.slice(0, normalizedSampleSize));
}
async fieldNamesForDeck(deckName: string, sampleSize = 100): Promise<string[]> {