diff --git a/CHANGES.md b/CHANGES.md index d366767..8707f8a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ ## 0.10.1 (unreleased) * Added `must` navigator +* Added `ATOM` navigator (thanks @rakeshp) ## 0.10.0 * Make codebase bootstrap cljs compatible diff --git a/src/clj/com/rpl/specter.cljx b/src/clj/com/rpl/specter.cljx index 738e24d..315c0fc 100644 --- a/src/clj/com/rpl/specter.cljx +++ b/src/clj/com/rpl/specter.cljx @@ -279,17 +279,6 @@ (assoc structure key (next-fn (get structure key))) )) -(defpath - ^{:doc "Navigates to atom value."} - ATOM - [] - (select* [this structure next-fn] - (next-fn @structure)) - (transform* [this structure next-fn] - (do - (reset! structure (next-fn @structure)) - structure))) - (defpath ^{:doc "Navigates to the key only if it exists in the map."} must @@ -320,6 +309,17 @@ (unparse-fn (next-fn (parse-fn structure))) )) +(defpath + ^{:doc "Navigates to atom value."} + ATOM + [] + (select* [this structure next-fn] + (next-fn @structure)) + (transform* [this structure next-fn] + (do + (swap! structure next-fn) + structure))) + (defn selected? "Filters the current value based on whether a path finds anything. e.g. (selected? :vals ALL even?) keeps the current element only if an