mirror of
https://github.com/penpot/penpot.git
synced 2026-03-06 18:21:09 +00:00
Improve parse-int util function.
It now accept a default value in case of parsing return NaN.
This commit is contained in:
@@ -42,5 +42,10 @@
|
||||
(r/read-string v))
|
||||
|
||||
(defn parse-int
|
||||
[v]
|
||||
(js/parseInt v 10))
|
||||
([v]
|
||||
(js/parseInt v 10))
|
||||
([v default]
|
||||
(let [v (js/parseInt v 10)]
|
||||
(if (or (not v) (nan? v))
|
||||
default
|
||||
v))))
|
||||
|
||||
Reference in New Issue
Block a user