mirror of
https://github.com/penpot/penpot.git
synced 2025-03-18 10:41:29 -05: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 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…
Add table
Reference in a new issue