From e4a93da8ea576a1d25f6164505f86ab6f4c44a05 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 27 Dec 2015 15:29:19 +0200 Subject: [PATCH] Add helpers for the reader and int parsing. --- frontend/uxbox/util/data.cljs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/uxbox/util/data.cljs b/frontend/uxbox/util/data.cljs index 8d3914b37..2320291cb 100644 --- a/frontend/uxbox/util/data.cljs +++ b/frontend/uxbox/util/data.cljs @@ -1,5 +1,10 @@ (ns uxbox.util.data - "A collection of data transformation utils.") + "A collection of data transformation utils." + (:require [cljs.reader :as r])) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Data structure manipulation +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn index-by "Return a indexed map of the collection @@ -17,3 +22,15 @@ pairs when value is `nil`." [data] (into {} (remove (comp nil? second) data))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Numbers Parsing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn read-string + [v] + (r/read-string v)) + +(defn parse-int + [v] + (js/parseInt v 10))