Initial select implementation for Regexes.
This commit is contained in:
parent
796ad700f7
commit
b5f840db22
2 changed files with 12 additions and 0 deletions
|
|
@ -1170,6 +1170,10 @@
|
||||||
ImplicitNav
|
ImplicitNav
|
||||||
(implicit-nav [this] (pred this)))
|
(implicit-nav [this] (pred this)))
|
||||||
|
|
||||||
|
(extend-type #?(:clj java.util.regex.Pattern :cljs RegExp)
|
||||||
|
ImplicitNav
|
||||||
|
(implicit-nav [this] (n/regex* this)))
|
||||||
|
|
||||||
(defnav
|
(defnav
|
||||||
^{:doc "Navigates to the provided val if the structure is nil. Otherwise it stays
|
^{:doc "Navigates to the provided val if the structure is nil. Otherwise it stays
|
||||||
navigated at the structure."}
|
navigated at the structure."}
|
||||||
|
|
|
||||||
|
|
@ -622,6 +622,14 @@
|
||||||
(do-keypath-transform vals structure key next-fn)
|
(do-keypath-transform vals structure key next-fn)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
(defrichnav ^{:doc "Navigates to the regex applied to a string, navigating to nil if it does not exist or nothing is found."}
|
||||||
|
;; Setting the value to NONE will remove it from the collection.}
|
||||||
|
regex*
|
||||||
|
[re]
|
||||||
|
(select* [this vals structure next-fn]
|
||||||
|
(next-fn vals (re-find re structure)))
|
||||||
|
#_(transform* [this vals structure next-fn]
|
||||||
|
(next-fn (clojure.string/replace structure re vals))))
|
||||||
|
|
||||||
(defrichnav
|
(defrichnav
|
||||||
^{:doc "Navigates to the key only if it exists in the map. Setting the value to NONE
|
^{:doc "Navigates to the key only if it exists in the map. Setting the value to NONE
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue