mirror of
https://github.com/penpot/penpot.git
synced 2026-05-02 22:58:35 +00:00
✨ Improve dm/get-in macro to be fully compliant with core/get-in
This commit is contained in:
parent
5eb53da374
commit
9e940dc042
@ -34,8 +34,12 @@
|
||||
`(-> ~target ~@(map (fn [key] (list `c/get key)) keys)))
|
||||
([target keys default]
|
||||
(assert (vector? keys) "keys expected to be a vector")
|
||||
`(let [v# (-> ~target ~@(map (fn [key] (list `c/get key)) keys))]
|
||||
(if (some? v#) v# ~default))))
|
||||
(let [last-index (dec (count keys))]
|
||||
`(-> ~target ~@(map-indexed (fn [index key]
|
||||
(if (= last-index index)
|
||||
(list `c/get key default)
|
||||
(list `c/get key)))
|
||||
keys)))))
|
||||
|
||||
(defmacro str
|
||||
[& params]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user