mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 04:11:44 +02:00
✨ Improve dm/get-in macro to be fully compliant with core/get-in
This commit is contained in:
parent
5eb53da374
commit
9e940dc042
1 changed files with 6 additions and 2 deletions
|
@ -34,8 +34,12 @@
|
||||||
`(-> ~target ~@(map (fn [key] (list `c/get key)) keys)))
|
`(-> ~target ~@(map (fn [key] (list `c/get key)) keys)))
|
||||||
([target keys default]
|
([target keys default]
|
||||||
(assert (vector? keys) "keys expected to be a vector")
|
(assert (vector? keys) "keys expected to be a vector")
|
||||||
`(let [v# (-> ~target ~@(map (fn [key] (list `c/get key)) keys))]
|
(let [last-index (dec (count keys))]
|
||||||
(if (some? v#) v# ~default))))
|
`(-> ~target ~@(map-indexed (fn [index key]
|
||||||
|
(if (= last-index index)
|
||||||
|
(list `c/get key default)
|
||||||
|
(list `c/get key)))
|
||||||
|
keys)))))
|
||||||
|
|
||||||
(defmacro str
|
(defmacro str
|
||||||
[& params]
|
[& params]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue