Spaces:
Sleeping
Sleeping
File size: 742 Bytes
3856d3e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | const BATCH_SIZE_STORAGE_KEY = 'imageBatchSize';
const DEFAULT_BATCH_SIZE = 10;
export function saveBatchSize(size: number): void {
if (size < 0) {
throw new Error('El tamaño del lote no puede ser negativo');
}
localStorage.setItem(BATCH_SIZE_STORAGE_KEY, size.toString());
}
export function getBatchSize(): number {
const stored = localStorage.getItem(BATCH_SIZE_STORAGE_KEY);
if (!stored) {
return DEFAULT_BATCH_SIZE;
}
const parsed = parseInt(stored, 10);
if (isNaN(parsed) || parsed < 0) {
return DEFAULT_BATCH_SIZE;
}
if (parsed >= 999999) {
return 0;
}
return parsed;
}
export function resetBatchSize(): void {
localStorage.removeItem(BATCH_SIZE_STORAGE_KEY);
}
|