mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 12:28:54 -05:00
⚡ Optimize d/mapm helper using reduce-kv
This commit is contained in:
parent
893a8992c3
commit
733825edfa
1 changed files with 5 additions and 2 deletions
|
@ -316,9 +316,12 @@
|
||||||
(defn mapm
|
(defn mapm
|
||||||
"Map over the values of a map"
|
"Map over the values of a map"
|
||||||
([mfn]
|
([mfn]
|
||||||
(map (fn [[key val]] [key (mfn key val)])))
|
(map (fn [[key val]] (vec2 key (mfn key val)))))
|
||||||
([mfn coll]
|
([mfn coll]
|
||||||
(into {} (mapm mfn) coll)))
|
(reduce-kv (fn [coll k v]
|
||||||
|
(assoc coll k (mfn k v)))
|
||||||
|
coll
|
||||||
|
coll)))
|
||||||
|
|
||||||
(defn removev
|
(defn removev
|
||||||
"Returns a vector of the items in coll for which (fn item) returns logical false"
|
"Returns a vector of the items in coll for which (fn item) returns logical false"
|
||||||
|
|
Loading…
Add table
Reference in a new issue