mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-27 00:55:16 -07:00
fix: normalize anki deck sample size
This commit is contained in:
+7
-1
@@ -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[]> {
|
||||
|
||||
Reference in New Issue
Block a user