fix: crash on tag round() with non-numeric argument
This commit is contained in:
parent
062cb053cc
commit
9fd2bf4edb
1 changed files with 4 additions and 1 deletions
|
@ -418,7 +418,10 @@ const baseValues = {
|
||||||
return Math.round(randValue * (to - from) + from);
|
return Math.round(randValue * (to - from) + from);
|
||||||
},
|
},
|
||||||
round(arg, decimals = 0) {
|
round(arg, decimals = 0) {
|
||||||
if (isNaN(arg)) return 0;
|
if (typeof arg !== "number") {
|
||||||
|
arg = parseFloat(arg);
|
||||||
|
}
|
||||||
|
if (Number.isNaN(arg)) return 0;
|
||||||
return decimals === 0 ? Math.round(arg) : arg.toFixed(Math.max(0, Math.min(decimals, 100)));
|
return decimals === 0 ? Math.round(arg) : arg.toFixed(Math.max(0, Math.min(decimals, 100)));
|
||||||
},
|
},
|
||||||
add(...args) {
|
add(...args) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue