0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 07:41:43 -05:00
penpot/frontend/uxbox/util/data.cljs
2015-12-30 00:19:48 +02:00

13 lines
372 B
Clojure

(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))