A bunch of utility functions
A bunch of utility functions
Takes a map and returns the map with kebab-cased keys.
Takes a map and returns the map with kebab-cased keys.
Takes a map and returns the map with snake_cased keys.
Takes a map and returns the map with snake_cased keys.
(->yes-no value)
If a value is truthy, returns the string "Yes". Else, return the string "No"
If a value is truthy, returns the string "Yes". Else, return the string "No"
(dissoc-in m [k & ks])
Dissoc the value in m
at ks
Dissoc the value in `m` at `ks`
(filter-by-keys f m)
Return m
with only the key:value pairs whose keys cause f
to evaluate truthily
Return `m` with only the key:value pairs whose keys cause `f` to evaluate truthily
(filter-by-values f m)
Return m
with only the key:value pairs whose values cause f
to evaluate truthily
Return `m` with only the key:value pairs whose values cause `f` to evaluate truthily
Split operator to generate v1 guids based on runtime env
Split operator to generate v1 guids based on runtime env
(pluralize given-string amount)
(pluralize given-string amount override-string)
Naively pluralize given-string
based on amount
Optionally, an override-string
can be passed for special cases:
e.g "peach" -> "peaches"
Naively pluralize `given-string` based on `amount` Optionally, an `override-string` can be passed for special cases: e.g "peach" -> "peaches"
(rand-key m)
Safely return a random key of a map, giving nil for empty maps
Safely return a random key of a map, giving nil for empty maps
(rand-kv m)
Return a random key-val pair of a map as a map. OPINIONATED: Empty collections return empty maps.
Return a random key-val pair of a map as a map. OPINIONATED: Empty collections return empty maps.
(rand-val m)
Safely return a random val of a map, giving nil for empty maps
Safely return a random val of a map, giving nil for empty maps
(remove-by-keys f m)
Return m
with only the key:value pairs whose keys cause f
to evaluate falsily
Return `m` with only the key:value pairs whose keys cause `f` to evaluate falsily
(remove-by-values f m)
Return m
with only the key:value pairs whose values cause f
to evaluate falsily
Return `m` with only the key:value pairs whose values cause `f` to evaluate falsily
(try-or-nil f & args)
Try applying f to args, returning nil in case of an Exception.
Try applying f to args, returning nil in case of an Exception.
(update-keys m f & args)
Return m
with f
applied to each key in m
with its args
Return `m` with `f` applied to each key in `m` with its `args`
(update-or-assoc m k v update-fn)
If k
exists in m
apply the update-fn
.
Else, assoc v
to that k
in m
If `k` exists in `m` apply the `update-fn`. Else, assoc `v` to that `k` in `m`
(update-vals m f & args)
Return m
with f
applied to each val in m
with its args
Return `m` with `f` applied to each val in `m` with its `args`
(uuid)
Split operator to generate v1 uuids based on runtime env
Split operator to generate v1 uuids based on runtime env
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close