0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

Add namespace for data transformation utils.

This commit is contained in:
Andrey Antukh 2015-12-25 15:26:40 +02:00
parent 66b6040f86
commit d8e7087af6

View file

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