fix toInt func
This commit is contained in:
parent
81e1305bff
commit
930163aa15
@ -58,7 +58,7 @@ const toInt = (v, def = 0, min = null, max = null) => {
|
|||||||
min = isFinite(min) ? (typeof min === 'string' ? parseInt(min) : min) : null
|
min = isFinite(min) ? (typeof min === 'string' ? parseInt(min) : min) : null
|
||||||
max = isFinite(max) ? (typeof max === 'string' ? parseInt(max) : max) : null
|
max = isFinite(max) ? (typeof max === 'string' ? parseInt(max) : max) : null
|
||||||
if (!isFinite(v)) return def
|
if (!isFinite(v)) return def
|
||||||
v = parseInt(v)
|
if (typeof v === 'string') v = parseInt(v)
|
||||||
if (min !== null && v < min) v = min
|
if (min !== null && v < min) v = min
|
||||||
if (max !== null && v > max) v = max
|
if (max !== null && v > max) v = max
|
||||||
return v
|
return v
|
||||||
|
Loading…
Reference in New Issue
Block a user