Bug Fix: rfmk and rfmv functions
Fixed bug where rfmk and rfmv could not handle vectors, sets, or sequences at the top level.
Error (before fix):
IllegalArgumentException: No implementation of method: :alter-name of protocol:
#'camel-snake-kebab.internals.alter-name/AlterName found for class: java.lang.Integer
Root cause: The functions called update-keys/update-vals directly on the input parameter,
assuming it was always a map. When a vector was passed, update-keys treated vector indices
(integers 0, 1, 2...) as keys and tried to transform them with the provided function.
Fix: Changed both functions to use their internal walk helper for the top-level input,
which correctly handles all data structures (maps, vectors, sets, sequences).
Example:
Before:
(rfmk [{:isPrimary true}] ->kebab-case)
;; => IllegalArgumentException: No implementation of AlterName for class: java.lang.Integer
After:
(rfmk [{:isPrimary true}] ->kebab-case)
;; => [{:is-primary true}]
Changes:
rfmk: Changed from (update-keys (update-vals m walk) f) to (walk m)rfmv: Changed from (update-vals m walk) to (walk m)Breaking changes: None. Existing code continues to work. This fix only makes previously-broken functionality work correctly.
update "yang.scheduler"
every function now:
task-name"(def s (every 1000
#(println "scanning asteroids"))) ;; default: "funtask", milliseconds
(:intel s) ;; => {:task-name "funtask"
;; :interval 1000
;; :time-unit :MILLISECONDS
;; :started-at [java.time.Instant "2025-03-22T12:34:56Z"]
;; :cancelled? #function[...]
;; :done? #function[...]
;; :running? #function[...]
;; :next-run #function[...]}
(def s2 (every 2
#(println "Beep from Mars")
{:task-name "rover-ping"
:time-unit TimeUnit/SECONDS}))
(:interval (:intel s2)) ;; => 2
((:next-run (:intel s2))) ;; => [java.time.Instant "2025-03-22T18:34:49.365088Z"]
(def s3 (every 1000
#(throw (RuntimeException. "no oxygen!"))
{:task-name "life-support"}))
;; prints: "problem running a scheduled task (\"life-support\") due to: java.lang.RuntimeException: no oxygen!"
;; but does not stop running
add "swallow"
add "remove-missing-paths":
=> (def m {:a 42 :m {:b 28 :c {:z 32} :d nil :w 34}})
=> (def s {:a 42 :m {:f 28 :c {:z 32 :g 12} :d 12 :z 21 :v 14} :k 18})
=> (remove-missing-paths m s)
{:kept {:a 42, :m {:c {:z 32}, :d 12}},
:removed ([:k] [:m :f] [:m :v] [:m :z] [:m :c :g])}"
moved reflection to the yang.java namespace
making most of yang babashka compatible
=> (require '[yang.lang :as y])
=> (def m {:moo 42})
=> (y/assoc-if m :zoo 12)
{:moo 42, :zoo 12}
;; nil is not a value: hence skipped
=> (y/assoc-if m :zoo 12 :moo nil)
{:moo 42, :zoo 12}
;; false is a value: hence not skipped
=> (y/assoc-if m :zoo 12 :moo nil :boo false)
{:moo 42, :zoo 12, :boo false}
filter-kv & map->keys-as-path (0af41e8 thanks to @sirmspencer)strip-margin function (4f92fd4 thanks to @danielmiladinov)Can you improve this documentation? These fine people already did:
anatoly, Pradeep George, tolitius & AnatolyEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |