parse-long

functionsince v1.11.50Edit
(parse-long s)

Source docstring:
Parse string of decimal digits with optional leading -/+ and return an
integer value, or nil if parse fails
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(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)))))