Liking cljdoc? Tell your friends :D

com.wsscode.misc.coll


*deep-merge-handlers*clj/s

source

assoc-ifclj/s

(assoc-if m k v)
(assoc-if m k v & kvs)

Like assoc, but noop if v is falsy.

Like assoc, but noop if v is falsy.
sourceraw docstring

coll-append-at-head?clj/s

(coll-append-at-head? s)

Return true if column add items at head with conj.

Return true if column add items at head with conj.
sourceraw docstring

collection?clj/s

(collection? x)

Returns true for sequential collections and sets, false for maps.

Returns true for sequential collections and sets, false for maps.
sourceraw docstring

conj-at-indexclj/s

(conj-at-index v idx x)

Add element to a vector at some specific index. Only works with vectors!

Add element to a vector at some specific index. Only works with vectors!
sourceraw docstring

dedupe-byclj/s

(dedupe-by f)
(dedupe-by f coll)

Returns a lazy sequence removing consecutive duplicates in coll when passed to a function f. Returns a transducer when no collection is provided.

Returns a lazy sequence removing consecutive duplicates in coll when passed to a function f.
Returns a transducer when no collection is provided.
sourceraw docstring

deep-mergeclj/s≠

clj
(deep-merge & maps)
cljs
(deep-merge)
(deep-merge a)
(deep-merge a b)
(deep-merge a b & more)

Recursively merges maps together. If all the maps supplied have nested maps under the same keys, these nested maps are merged.

A custom merge strategy may be configured for specific keys, to do so you need to bind the value of deep-merge-handlers, the keys are the keywords and the values are functions to handle the merge of that key.

(binding [*deep-merge-handlers* {:foo +}]
  (deep-merge {:foo 1} {:foo 2}))
; => {:foo 3}

Another way to control the merge of values is to set some metadata to control the merge process (notice it only applies for types that support meta like maps and vectors, but not for keywords or numbers for example).

(deep-merge {:list [1 2 3]} ^{::merge-with into} {:list [:a :b]})
; => {:list [1 2 3 :a :b]}

The meta may go in the left or side of the merge, the right side has higher priority.

Note that meta mergers have higher priority than merge handlers.

Here is the merger pick order for clarity:

  1. Value merger from meta at new value
  2. Value merger from meta at current value
  3. Merge key handler
  4. Deep merge (in case both values are maps)
  5. Keep the new value (as in clojure.core/merge)

Forked from Medley library.

Recursively merges maps together. If all the maps supplied have nested maps
under the same keys, these nested maps are merged.

A custom merge strategy may be configured for specific keys, to do so you need to
bind the value of *deep-merge-handlers*, the keys are the keywords and the values
are functions to handle the merge of that key.

    (binding [*deep-merge-handlers* {:foo +}]
      (deep-merge {:foo 1} {:foo 2}))
    ; => {:foo 3}

Another way to control the merge of values is to set some metadata to control the
merge process (notice it only applies for types that support meta like maps and vectors,
but not for keywords or numbers for example).

    (deep-merge {:list [1 2 3]} ^{::merge-with into} {:list [:a :b]})
    ; => {:list [1 2 3 :a :b]}

The meta may go in the left or side of the merge, the right side has higher priority.

Note that meta mergers have higher priority than merge handlers.

Here is the merger pick order for clarity:

1. Value merger from meta at new value
2. Value merger from meta at current value
3. Merge key handler
4. Deep merge (in case both values are maps)
5. Keep the new value (as in `clojure.core/merge`)

Forked from Medley library.
sourceraw docstring

distinct-byclj/s

(distinct-by f)
(distinct-by f coll)

Returns a lazy sequence of the elements of coll, removing any elements that return duplicate values when passed to a function f.

Returns a lazy sequence of the elements of coll, removing any elements that
return duplicate values when passed to a function f.
sourceraw docstring

filter-keysclj/s

(filter-keys f m)
source

filter-valsclj/s

(filter-vals f m)
source

find-firstclj/s

(find-first f coll)

Return the first element in coll that returns true for f.

Return the first element in coll that returns true for f.
sourceraw docstring

index-byclj/s

(index-by f coll)

Like group by, but will keep only the last result.

Like group by, but will keep only the last result.
sourceraw docstring

index-ofclj/s

(index-of coll x)

Find the index of element x in coll. Return nil if element is not found.

Find the index of element x in coll. Return nil if element is not found.
sourceraw docstring

iterate-whileclj/s

(iterate-while f x)

Like iterate, but stops when it sees a nil value.

Like iterate, but stops when it sees a `nil` value.
sourceraw docstring

iteratorclj/s

(iterator coll)

CLJC utility to get an iterator from the collection.

CLJC utility to get an iterator from the collection.
sourceraw docstring

keep-currentclj/s

(keep-current a _)

Merge util to keep the value from the left side.

Merge util to keep the value from the left side.
sourceraw docstring

keep-newclj/s

(keep-new _ b)

Merge util to keep the value from the right side.

Merge util to keep the value from the right side.
sourceraw docstring

keys-setclj/s

(keys-set m)

Return the map keys, as a set. This also checks if the entry is a map, otherwise returns nil (instead of throw).

Return the map keys, as a set. This also checks if the entry is a map, otherwise
returns nil (instead of throw).
sourceraw docstring

make-map-entryclj/s

(make-map-entry k v)

CLJC helper to create MapEntry.

CLJC helper to create MapEntry.
sourceraw docstring

map-keysclj/s

(map-keys f m)

Map over the given hash-map keys.

Example: (map-keys #(str/replace (name %) "_" "-") {"foo_bar" 1}) => {"foo-bar" 1}

Map over the given hash-map keys.

Example:
  (map-keys #(str/replace (name %) "_" "-") {"foo_bar" 1}) => {"foo-bar" 1}
sourceraw docstring

map-valsclj/s

(map-vals f m)

Map over the given hash-map vals.

Example: (map-vals inc {:a 1 :b 2})

Map over the given hash-map vals.

Example:
  (map-vals inc {:a 1 :b 2})
sourceraw docstring

merge-defaultsclj/s

(merge-defaults m defaults)

Like merge, but only add keys that are not present in the original map.

Like merge, but only add keys that are not present in the original map.
sourceraw docstring

merge-growclj/s

(merge-grow)
(merge-grow a)
(merge-grow a b)

Additive merging.

When merging maps, it does a deep merge. When merging sets, makes a union of them.

When value of the right side is nil, the left side will be kept.

For the rest works as standard merge.

Additive merging.

When merging maps, it does a deep merge.
When merging sets, makes a union of them.

When value of the right side is nil, the left side will be kept.

For the rest works as standard merge.
sourceraw docstring

native-map?clj/s

(native-map? x)
source

queueclj/s

(queue)
(queue coll)

Return a blank immutable queue or create one from coll.

Return a blank immutable queue or create one from coll.
sourceraw docstring

remove-keysclj/s

(remove-keys f m)
source

remove-valsclj/s

(remove-vals f m)
source

restore-orderclj/s

(restore-order inputs key items)
(restore-order inputs key items default-fn)

Sorts output list to match input list order.

(coll/restore-order [{:id 1} {:id 2} {:id 3}] :id [{:id 4 :x "a"} {:id 1 :x "b"} {:id 3 :x "c"} {:id 2 :x "d"}])

=> [{:id 1 :x "b"} {:id 2 :x "d"} {:id 3 :x "c"}]

Note it will also remove items that don't match anything in the original items list.

In case the items contains a matching key more than once, the last one will be taken.

Sorts output list to match input list order.

   (coll/restore-order
     [{:id 1} {:id 2} {:id 3}]
     :id
     [{:id 4 :x "a"}
      {:id 1 :x "b"}
      {:id 3 :x "c"}
      {:id 2 :x "d"}])

   => [{:id 1 :x "b"}
       {:id 2 :x "d"}
       {:id 3 :x "c"}]

Note it will also remove items that don't match anything in the original items
list.

In case the items contains a matching key more than once, the last one will be taken.
sourceraw docstring

restore-order2clj/s

(restore-order2 inputs key items)
(restore-order2 inputs key default-fn items)

Same functionality as restore-order, but fixes the arguments order to make it easier to thread with a default-fn.

Also, it returns nil for not found items instead of a map with the key.

Same functionality as restore-order, but fixes the arguments order to make
it easier to thread with a default-fn.

Also, it returns nil for not found items instead of a map with the key.
sourceraw docstring

sconjclj/s

source

update-containedclj/s

(update-contained m k f)
(update-contained m k f a1)
(update-contained m k f a1 a2)
(update-contained m k f a1 a2 a3)
(update-contained m k f a1 a2 a3 & args)

Update some key when that key is present in the map.

Update some key when that key is present in the map.
sourceraw docstring

update-ifclj/s

(update-if m k f)
(update-if m k f a1)
(update-if m k f a1 a2)
(update-if m k f a1 a2 a3)
(update-if m k f a1 a2 a3 & args)

Update some key if that key is present in the map and value is truthy.

Update some key if that key is present in the map and value is truthy.
sourceraw docstring

value-mergerclj/s

(value-merger x)
source

vconjclj/s

source

vector-compareclj/s

(vector-compare [value1 & rest1] [value2 & rest2])

Compare two vectors, this expects the vectors to be ordered.

Compare two vectors, this expects the vectors to be ordered.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close