function | since v1.11.50 | Edit |
(parse-long s)
Parse string of decimal digits with optional leading -/+ and return an integer value, or nil if parse fails
(defn ^number parse-long
[s]
(if (string? s)
(and (re-matches #"[+-]?\d+" s)
(let [i (js/parseInt s)]
(when (and (<= i js/Number.MAX_SAFE_INTEGER)
(>= i js/Number.MIN_SAFE_INTEGER))
i)))
(throw (js/Error. (parsing-err s)))))