io.jesi.backpack.collection
assoc-in
(assoc-in m & kvs)
assoc-some!
(assoc-some! tmap k v)
Assocs some value into a transitive map
collify
(collify)
(collify v)
Puts value v
in a vector if it is not a collection. Returns nil
if no value
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)
create-index
(create-index ks)
default-changed-merger
default-comparator
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?)
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)
in?
(in? col el)
index-comparator
(index-comparator idx)
(index-comparator idx not-found-fn)
Returns a comparator function that sorts based on the provided idx
map. Takes an optional not-found-fn
that’s called when a key is not found in the idx
, takes a key and returns a sort index. The default not-found-fn
returns the count of idx
.
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
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
rename-keys!
(rename-keys! tmap kmap)
Returns the transient map with the keys in kmap renamed to the vals in kmap
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
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
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