diff --git a/src/clj/com/rpl/specter/navs.cljc b/src/clj/com/rpl/specter/navs.cljc index a587402..3cd1084 100644 --- a/src/clj/com/rpl/specter/navs.cljc +++ b/src/clj/com/rpl/specter/navs.cljc @@ -95,6 +95,13 @@ (comp (map next-fn) (filter not-NONE?)) structure)) + + #?(:clj String :cljs string) + (all-transform [structure next-fn] + (apply str (into [] + (comp (map next-fn) + (filter not-NONE?)) + structure))) #?(:clj clojure.lang.PersistentHashSet :cljs cljs.core/PersistentHashSet) (all-transform [structure next-fn] diff --git a/test/com/rpl/specter/core_test.cljc b/test/com/rpl/specter/core_test.cljc index 1ba123c..e8b416c 100644 --- a/test/com/rpl/specter/core_test.cljc +++ b/test/com/rpl/specter/core_test.cljc @@ -1440,6 +1440,11 @@ (is (= "abq" (setval s/LAST "q" "abc"))) ) +(deftest string-transform-test + (is (= "123" (transform s/ALL identity "123"))) + (is (= "123" (setval [s/ALL #(Character/isWhitespace %)] s/NONE "1 2 3"))) + (is (= "123" (transform [(s/filterer #(Character/isWhitespace %))] s/NONE "1 2 3")))) + (deftest regex-navigation-test ;; also test regexes as implicit navs (is (= (select #"t" "test") ["t" "t"]))