Liking cljdoc? Tell your friends :D

uk.axvr.refrain

Collection of useful Clojure utilities.

Collection of useful Clojure utilities.
raw docstring

->mapclj/smacro

(->map & ks)

Like {} but can omit keys when you want it to be the same as the symbol bound to the value. Useful for avoiding unnecessary repetition during map construction. At >9 key-value pairs, switches from an array-map to a hash-map just like {}.

(let [[a b c d] (range)]
  (->map a b :c1 c d))
;; => {:a 0, :b 1, :c1 2, :d 3}
Like `{}` but can omit keys when you want it to be the same as the symbol
bound to the value.  Useful for avoiding unnecessary repetition during map
construction.  At >9 key-value pairs, switches from an array-map to
a hash-map just like `{}`.

    (let [[a b c d] (range)]
      (->map a b :c1 c d))
    ;; => {:a 0, :b 1, :c1 2, :d 3}
sourceraw docstring

assoc*clj/s

(assoc* m & kvs)

Like clojure.core/assoc, but won't assoc if key or val is nil.

Like `clojure.core/assoc`, but won't assoc if key or val is nil.
sourceraw docstring

contrastclj/s

(contrast op)
(contrast op obj & objs)

Contrast multiple comparable objects with each other with op. (Wrapper around clojure.core/compare.) Example ops: < > <= >= = not=

Contrast multiple comparable objects with each other with op.  (Wrapper
around `clojure.core/compare`.)  Example ops: < > <= >= = not=
sourceraw docstring

deep-mergeclj/s

(deep-merge & colls)

Like clojure.core/merge, but recursively merges maps.

Like `clojure.core/merge`, but recursively merges maps.
sourceraw docstring

deep-merge-withclj/s

(deep-merge-with _ coll)
(deep-merge-with f c1 c2)
(deep-merge-with f c1 c2 & cs)

Like clojure.core/merge-with, but recursively merges maps.

Like `clojure.core/merge-with`, but recursively merges maps.
sourceraw docstring

derefable?clj/s

(derefable? ref)

Returns true if clojure.core/deref can be called on ref.

Returns true if `clojure.core/deref` can be called on ref.
sourceraw docstring

dissoc-inclj/s

(dissoc-in m [k & ks])

Dissociates an entry from a nested associative structure returning a new nested structure. ks is a sequence of keys. Any empty maps that result will not be present in the new structure.

Dissociates an entry from a nested associative structure returning a new
nested structure.  ks is a sequence of keys.  Any empty maps that result
will not be present in the new structure.
sourceraw docstring

expectclj/smacro

(expect data pred)
(expect data pred msg)

Perform an assertion against a predicate. Returns data on success.

(-> {:status 200, :body "Foo bar"} (expect (comp #{200 201 202} :status) "HTTP response status code was not successful.") :body)

Perform an assertion against a predicate.  Returns `data` on success.

(-> {:status 200, :body "Foo bar"}
    (expect (comp #{200 201 202} :status)
            "HTTP response status code was not successful.")
    :body)
sourceraw docstring

expect'clj/s

(expect' pform pval msg)

Implementation detail of the expect macro. Do not use this directly.

Implementation detail of the `expect` macro.  Do not use this directly.
sourceraw docstring

expectationclj/smacro

(expectation pred)
(expectation pred msg)

Constructs and returns an assertion function that checks input against a predicate, returns given input on success.

(def successful-resp? #(<= 200 % 299))

(def fetch
  (comp :body (expectation successful-resp?) http/get))

(-> "https://example.com" fetch :body)
Constructs and returns an assertion function that checks input against
a predicate, returns given input on success.

    (def successful-resp? #(<= 200 % 299))

    (def fetch
      (comp :body (expectation successful-resp?) http/get))

    (-> "https://example.com" fetch :body)
sourceraw docstring

in?clj/s

(in? coll elm)

Returns true if coll contains elm.

Returns true if coll contains elm.
sourceraw docstring

macro-body-optsclj/s

(macro-body-opts [opts & body :as params])

Helper for creating macros that accept an optional map of options in their body. Call this function in your macro on the rest-body param and it will return a vector containing the option map and the rest of the body.

An option map will be found if there were more than one form in the body and the first form is a map.

Helper for creating macros that accept an optional map of options in their
body.  Call this function in your macro on the rest-body param and it will
return a vector containing the option map and the rest of the body.

An option map will be found if there were more than one form in the body and
the first form is a map.
sourceraw docstring

read-edn-resourceclj

(read-edn-resource path)
(read-edn-resource path opts)

Read an EDN file at path from JVM resources.

Read an EDN file at path from JVM resources.
sourceraw docstring

regexp?clj/s≠

clj
(regexp? x)

Returns true if x is a Java regular expression pattern.

Returns true if x is a Java regular expression pattern.
cljs

Alias to cljs.core/regexp?. This exists purely to make writing *.cljc files that need regexp? easier.

Alias to `cljs.core/regexp?`.  This exists purely to make writing *.cljc
files that need `regexp?` easier.
source (clj)source (cljs)raw docstring

submap?clj/s

(submap? map1 map2)

Returns true if map1 is a subset of map2.

Returns true if map1 is a subset of map2.
sourceraw docstring

trim-endclj/s

(trim-end s substr)

Trim substr from the end of s.

Trim substr from the end of s.
sourceraw docstring

trim-startclj/s

(trim-start s substr)

Trim substr from the start of s.

Trim substr from the start of s.
sourceraw docstring

when-let*clj/smacro

(when-let* bindings & body)

Short circuiting version of clojure.core/when-let on multiple binding forms.

Short circuiting version of `clojure.core/when-let` on multiple binding
forms.
sourceraw docstring

with-gensymsclj/smacro

(with-gensyms syms & body)

Bulk generate "gensym" values and bind them to each symbol in "syms".

Bulk generate "gensym" values and bind them to each symbol in "syms".
sourceraw docstring

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

× close