mirror of
https://github.com/penpot/penpot.git
synced 2025-07-31 18:18:30 +02:00
Improve parse-int util function.
It now accept a default value in case of parsing return NaN.
This commit is contained in:
parent
046360bd14
commit
da5d9c2422
1 changed files with 7 additions and 2 deletions
|
@ -42,5 +42,10 @@
|
||||||
(r/read-string v))
|
(r/read-string v))
|
||||||
|
|
||||||
(defn parse-int
|
(defn parse-int
|
||||||
[v]
|
([v]
|
||||||
(js/parseInt v 10))
|
(js/parseInt v 10))
|
||||||
|
([v default]
|
||||||
|
(let [v (js/parseInt v 10)]
|
||||||
|
(if (or (not v) (nan? v))
|
||||||
|
default
|
||||||
|
v))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue