Normalize number setting: Handle null, undefined, and empty string inputs
This commit is contained in:
@@ -166,6 +166,7 @@ function clamp(value, min, max) {
|
||||
}
|
||||
|
||||
function normalizeNumberSetting(value, fallback, { min, max, integer = false } = {}) {
|
||||
if (value === null || value === undefined || (typeof value === 'string' && value.trim() === '')) return fallback;
|
||||
const parsed = Number(value);
|
||||
if (!Number.isFinite(parsed)) return fallback;
|
||||
const rounded = integer ? Math.trunc(parsed) : parsed;
|
||||
|
||||
Reference in New Issue
Block a user