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:
parent
66b6040f86
commit
d8e7087af6
1 changed files with 13 additions and 0 deletions
13
frontend/uxbox/util/data.cljs
Normal file
13
frontend/uxbox/util/data.cljs
Normal 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))
|
Loading…
Add table
Reference in a new issue