From d8e7087af625078e04e218cb8376033279624257 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 25 Dec 2015 15:26:40 +0200 Subject: [PATCH] Add namespace for data transformation utils. --- frontend/uxbox/util/data.cljs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 frontend/uxbox/util/data.cljs diff --git a/frontend/uxbox/util/data.cljs b/frontend/uxbox/util/data.cljs new file mode 100644 index 000000000..54801509d --- /dev/null +++ b/frontend/uxbox/util/data.cljs @@ -0,0 +1,13 @@ +(ns uxbox.util.data + "A collection of data transformation utils.") + +(defn index-by + "Return a indexed map of the collection + keyed by the result of executing the getter + over each element of the collection." + [coll getter] + (let [data (transient {})] + (run! #(assoc! data (getter %) %) coll) + (persistent! data))) + +(def ^:static index-by-id #(index-by % :id))