io.jesi.backpack
->camelCase
(->camelCase s)
->camelCase-key
->comparator
(->comparator val-fn)
Returns a comparator where values returning from a value function are compared against
->kebab-case
(->kebab-case s)
->kebab-case-key
->proper-case
(->proper-case s)
->snake_case
(->snake_case s)
->snake_case-key
->uri
(->uri s)
->uuid
multimethod
Coerces a value into a UUID if possible, otherwise returns nil
->uuid-or-not
(->uuid-or-not id)
add-shutdown-hook
macro
(add-shutdown-hook & body)
Adds a shutdown hook using java.lang.Runtime.addShutdownHook. Returns the created Thread
add-shutdown-hook-fn
(add-shutdown-hook-fn f)
Adds a shutdown hook using java.lang.Runtime.addShutdownHook. Takes a function f
, and returns the created Thread
and-fn
(and-fn pred & more)
Higher order and
. Takes any number of predicates and returns a function that takes a value and returns true if ALL individual predicates return true, else return false.
any?
(any? pred coll)
Returns true if any item in coll returns true for pred, otherwise false
apply-when
(apply-when f v)
Invokes f when it’s truthy
assoc-in
(assoc-in m & kvs)
assoc-some!
(assoc-some! tmap k v)
Assocs some value into a transitive map
blank?
Similar to clojure.string/blank? but returns false if given a non-string
call
(call f v)
Calls the function f
with a value v
close
multimethod
collify
(collify)
(collify v)
Puts value v
in a vector if it is not a collection. Returns nil
if no value
compr
(compr)
(compr f)
(compr f g)
(compr f g & more)
Composes functions left to right, the opposite of comp
concat!
(concat!)
(concat! tcoll)
(concat! tcoll seq)
(concat! tcoll seq & more)
Adds the values to the transient collection, returning tcoll. Concatenates of the elements in the supplied sequences
conj!
(conj!)
(conj! tcoll)
(conj! tcoll val)
(conj! tcoll val & more)
Adds val to the transient collection, and return tcoll. The ‘addition’ may happen at different ‘places’ depending on the concrete type.
conj-some!
(conj-some! tcoll v)
Adds a value to the transitive collection if some
contains-any?
(contains-any? map & keys)
d#
(d# a)
Derefs a value if it is derefable
default-changed-merger
default-comparator
defkw-type
(defkw-type type kw & args)
diff
(diff existing updated)
(diff leaf-pred existing updated)
(diff leaf-pred comparator existing updated)
(diff leaf-pred comparator changed-merger existing updated)
Returns a map of paths which have changed :added, :changed, :removed, and :same
dissoc-all
(dissoc-all map & keys)
dissoc-in
(dissoc-in m path & paths)
Dissociates paths from a map. Any empty maps produced will be removed
distinct-by
(distinct-by key entities)
distinct-vals?
(distinct-vals? m)
Returns true if all the map values are unique
empty->nil
(empty->nil x)
Returns nil
if argument returns true
for (clojure.core/empty?)
exception?
(exception? x)
Returns true
if x is a Clojure Throwable or ClojureScript js/Error
filter-by
(filter-by key-fn pred coll)
Filters a collection where a key matches a predicate e.g. (let [coll [{:id 1} {:id 2}] (filter-by :id (bp/p= 1) coll)) ; returns `({:id 1})
filter-empty
filter-key=
(filter-key= key-fn value coll)
Filters a collection where a key matches a value e.g. (let [coll [{:id 1} {:id 2}] (filter-key= :id 1 coll)) ; returns `({:id 1})
filter-nil-keys
(filter-nil-keys map)
Filters out all nil key values from a map
filter-values
(filter-values pred map)
first-some
(first-some m & ks)
if-fn
(if-fn pred then)
(if-fn pred then else)
Higher-order if function. Takes a predicate (pred
), calling then
or (optionally) else
based on the predicate. Returns nil if no else
defined.
in?
(in? col el)
infinity
Java’s Integer/MAX_VALUE for consistence use in Clojure(Script) projects
java->clj
(java->clj j)
(java->clj j key-fn)
Transforms Java to Clojure. Converting keys to kebab-case keywords by default
kebab->proper-case
(kebab->proper-case s)
kebab-case->Proper-Kebab-Case
(kebab-case->Proper-Kebab-Case kebab-case-str)
macro?
(macro? sym)
True if the provided sym
is a macro
map-if
(map-if pred f col)
map-key-walker
map-leaves
(map-leaves f coll)
(map-leaves f leaf-pred coll)
Traverses and applies the mapping function to each leaf of a data structure. The mapping function is given the path and value at that path
map-walker
mod
(mod num div)
Modulus of num and div supporting float and decimal values. Truncates toward negative infinity.
named?
(named? x)
Returns true if x
is named (can be passed to name
)
namespaced?
(namespaced? named)
Returns true if the named
has a namespace
noop
not-blank?
or-fn
(or-fn pred & more)
Higher order or
. Takes any number of predicates and returns a function that takes a value and returns true if ANY individual predicates return true, else return false.
p=
(p= & x)
Partial =
partial-right
(partial-right f & args)
pass
(pass f)
pass-if
(pass-if pred f)
path-walker
A spectre recursive path navigator, that collects all paths to the occurrences of leaves that match the given predicate. Does not traverse deeper into the matched structures.
pprint-str
(pprint-str object)
pprint-str-code
(pprint-str-code object)
prefix
re-quote
(re-quote s)
Quotes the regex string
redact
(redact keys m)
(redact keys m redacted-value)
Deeply replaces value of all the keys
in m
with the redacted-value
reduce-leaves
(reduce-leaves f coll)
(reduce-leaves f init coll)
(reduce-leaves f init leaf-pred coll)
Traverses and reduces a data structure where the reducing function is given an accumulator, vector path and value at that path
remove-empty
(remove-empty x)
remove-nil-vals
(remove-nil-vals map)
Shallowly removes nil values from a map
remove-prefix
(remove-prefix prefix s)
(remove-prefix prefix separator s)
Removes the prefix if the string starts with it otherwise ignores, is case sensitive
rename-keys!
(rename-keys! tmap kmap)
Returns the transient map with the keys in kmap renamed to the vals in kmap
round-to
(round-to precision d)
Rounds a given value ‘d’ to the specified ‘precision’
safe-empty?
(safe-empty? x)
select-non-nil-keys
(select-non-nil-keys m keys)
select-vals
(select-vals m ks)
Selects all values from a map using specified keys. Missing keys return nil
sorted-map-by-index
(sorted-map-by-index idx & keyvals)
sorted-map-by-order
(sorted-map-by-order ks & keyvals)
sorted?
(sorted? coll)
(sorted? comp coll)
True if a collection is sorted by means of a 2 or 3 way comparator
split-at-first
(split-at-first value s)
Splits s at the first occurrence of value, returns nil when s is empty
subs
(subs s start)
(subs s start end)
subs-inc
(subs-inc match s)
Returns the substring of ‘s’ up to and including the ‘match’ or nil
subs-to
(subs-to match s)
Returns the substring of ‘s’ up until the ‘match’
suffix
throw-if-throwable
(throw-if-throwable ex)
Throw ex if it’s an exception. Retains the message, data, and cause
trans-reduce
(trans-reduce f [c & coll])
(trans-reduce f init coll)
trans-reduce-kv
(trans-reduce-kv f init coll)
transform-keys
(transform-keys f coll)
Recursively transforms all map keys in coll with f
translate-keys
(translate-keys kmap map)
Updates map with the keys from kmap
true-string?
(true-string? s)
True if ‘s’ is the string literal ‘true’
update!
(update! tcoll k f)
(update! tcoll k f x)
(update! tcoll k f x y)
(update! tcoll k f x y z)
(update! tcoll k f x y z & more)
‘Updates’ a value in an transient associative structure, where k is a key and f is a function that will take the old value and any supplied args and return the new value, and returns a new structure. If the key does not exist, nil is passed as the old value.
update-some
(update-some m k f & args)
Updates a key in a map with a function, only if the key is present and the result of f
is not nil.
update-some!
(update-some! tmap k f)
Replaces the value of a key in a transitive map if the result of the function is some
uuid-str?
(uuid-str? s)
True if ‘s’ is a string and matches the UUID format
xor
(xor)
(xor x)
(xor x y)
(xor x y & more)
Returns true
only if one argument is true