mirror of
https://github.com/penpot/penpot.git
synced 2025-04-01 01:21:21 -05:00
📎 Add helpers for instrumenting vars
This commit is contained in:
parent
32b8a2c243
commit
b54bf2bba4
1 changed files with 20 additions and 0 deletions
|
@ -144,3 +144,23 @@
|
||||||
[system & {:as params}]
|
[system & {:as params}]
|
||||||
(enable-objects-map-feature-on-file! system params)
|
(enable-objects-map-feature-on-file! system params)
|
||||||
(enable-pointer-map-feature-on-file! system params))
|
(enable-pointer-map-feature-on-file! system params))
|
||||||
|
|
||||||
|
(defn instrument-var
|
||||||
|
[var]
|
||||||
|
(alter-var-root var (fn [f]
|
||||||
|
(let [mf (meta f)]
|
||||||
|
(if (::original mf)
|
||||||
|
f
|
||||||
|
(with-meta
|
||||||
|
(fn [& params]
|
||||||
|
(tap> params)
|
||||||
|
(let [result (apply f params)]
|
||||||
|
(tap> result)
|
||||||
|
result))
|
||||||
|
{::original f}))))))
|
||||||
|
|
||||||
|
(defn uninstrument-var
|
||||||
|
[var]
|
||||||
|
(alter-var-root var (fn [f]
|
||||||
|
(or (::original (meta f)) f))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue