File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed
Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change 365365 `(when-let [checked# (cljs.spec/instrument* ~v)]
366366 (set! ~sym checked#)
367367 ~v)))
368+
369+ (defmacro unstrument
370+ " Undoes instrument on the var at v, a var or symbol. Idempotent." [v]
371+ (let [v (if-not (seq? v) (list 'var v) v)
372+ sym (second v)]
373+ `(when-let [raw# (cljs.spec/unstrument* ~v)]
374+ (set! ~sym raw#)
375+ ~v)))
Original file line number Diff line number Diff line change 331331 checked))))
332332 (throw (no-fn-specs v specs)))))
333333
334- ; (defn unstrument
335- ; "Undoes instrument on the var at v, a var or symbol. Idempotent."
336- ; [v]
337- ; (let [v (->var v)]
338- ; (locking instrumented-vars
339- ; (when-let [{:keys [raw wrapped]} (get @instrumented-vars v)]
340- ; (let [current @v]
341- ; (when (= wrapped current)
342- ; (alter-var-root v (constantly raw))))
343- ; (swap! instrumented-vars dissoc v))
344- ; v)))
345- ;
334+ (defn unstrument*
335+ [v]
336+ (locking instrumented-vars
337+ (when-let [{:keys [raw wrapped]} (get @instrumented-vars v)]
338+ (let [current @v]
339+ (when (= wrapped current)
340+ raw))
341+ (swap! instrumented-vars dissoc v))
342+ v))
343+
346344; (defn speced-vars
347345; "Returns the set of vars whose namespace is in ns-syms AND
348346; whose vars have been speced with fdef. If no ns-syms are
You can’t perform that action at this time.
0 commit comments