diff --git a/src/clj/com/rpl/specter.cljx b/src/clj/com/rpl/specter.cljx index a01941f..1b799fd 100644 --- a/src/clj/com/rpl/specter.cljx +++ b/src/clj/com/rpl/specter.cljx @@ -135,6 +135,17 @@ ;; Built-in pathing and context operations +(defpath + ^{:doc "Stops navigation at this point. For selection returns nothing and for + transformation returns the structure unchanged"} + VOID + [] + (select* [this structure next-fn] + nil ) + (transform* [this structure next-fn] + structure + )) + (def ALL (comp-paths (i/->AllStructurePath))) (def VAL (i/->ValCollect)) diff --git a/test/com/rpl/specter/core_test.cljx b/test/com/rpl/specter/core_test.cljx index 0ab8838..cd5848d 100644 --- a/test/com/rpl/specter/core_test.cljx +++ b/test/com/rpl/specter/core_test.cljx @@ -566,6 +566,18 @@ (s/setval [:a s/NIL->VECTOR s/END] [:b] nil))) ) +(defspec void-test + (for-all+ + [s1 (gen/vector (limit-size 5 gen/int))] + (and + (empty? (s/select s/VOID s1)) + (empty? (s/select [s/VOID s/ALL s/ALL s/ALL s/ALL] s1)) + (= s1 (s/transform s/VOID inc s1)) + (= s1 (s/transform [s/ALL s/VOID s/ALL] inc s1)) + (= (s/transform [s/ALL (s/cond-path even? nil odd? s/VOID)] inc s1) + (s/transform [s/ALL even?] inc s1)) + ))) + #+clj (deftest large-params-test (let [path (apply s/comp-paths (repeat 25 s/keypath))