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
(only coll)
Attempt to return the first and only element in coll
.
If the collection does not contain exactly one element, throw an exception
Attempt to return the first and only element in `coll`. If the collection does not contain exactly one element, throw an exception
Attempt to return the first and only key in a map. If the map does not contain exactly one key:value pair, throw an exception
Attempt to return the first and only key in a map. If the map does not contain exactly one key:value pair, throw an exception
Attempt to return the first and only value in a map. If the map does not contain exactly one key:value pair, throw an exception
Attempt to return the first and only value in a map. If the map does not contain exactly one key:value pair, throw an exception
(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
(rcomp & fns)
Right-compose a list of functions: like comp, but in the opposite direction.
Right-compose a list of functions: like comp, but in the opposite direction.
(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
(rpartial f & args)
Right-partial a list of functions: like partial, but in the opposite direction.
Right-partial a list of functions: like partial, but in the opposite direction.
(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