mirror of
https://github.com/penpot/penpot.git
synced 2025-07-29 13:57:12 +02:00
♻️ Refactor custom stroke
This commit is contained in:
parent
bf5f845789
commit
6cbbfa6499
7 changed files with 166 additions and 137 deletions
|
@ -27,17 +27,18 @@
|
|||
(js/Object.keys ^js obj))
|
||||
|
||||
(defn get-in
|
||||
[obj keys]
|
||||
(loop [key (first keys)
|
||||
keys (rest keys)
|
||||
res obj]
|
||||
(if (nil? key)
|
||||
res
|
||||
(if (nil? res)
|
||||
res
|
||||
(recur (first keys)
|
||||
(rest keys)
|
||||
(unchecked-get res key))))))
|
||||
([obj keys]
|
||||
(get-in obj keys nil))
|
||||
|
||||
([obj keys default]
|
||||
(loop [key (first keys)
|
||||
keys (rest keys)
|
||||
res obj]
|
||||
(if (or (nil? key) (nil? res))
|
||||
(or res default)
|
||||
(recur (first keys)
|
||||
(rest keys)
|
||||
(unchecked-get res key))))))
|
||||
|
||||
(defn without
|
||||
[obj keys]
|
||||
|
@ -68,6 +69,14 @@
|
|||
(unchecked-set obj key value)
|
||||
obj)
|
||||
|
||||
(defn update!
|
||||
[obj key f & args]
|
||||
(let [found (get obj key ::not-found)]
|
||||
(if-not (identical? ::not-found found)
|
||||
(do (unchecked-set obj key (apply f found args))
|
||||
obj)
|
||||
obj)))
|
||||
|
||||
(defn- props-key-fn
|
||||
[key]
|
||||
(if (or (= key :class) (= key :class-name))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue