Liking cljdoc? Tell your friends :D
Mostly clj/s.
Exceptions indicated.

taoensso.encore

Extended core library for Clojure/Script that emphasizes:

  • Cross platform API compatibility
  • Flexibility
  • Performance
  • Backwards compatibility

This lib's mostly for my own use and for advanced users that feel comfortable reading this source. Not providing much beginner-oriented documentation for this, sorry.

Quick Taoensso naming conventions: foo - Dynamic var foo! - Fn with side effects, or that should otherwise be used cautiously foo? - Truthy val or fn that returns truthy val foo!? - Fn that has side effects (or requires caution) and that return a truthy val. Note: !?, not ?! foo$ - Fn that's notably expensive to compute (e.g. hits db) foo_ - Derefable val (e.g. atom, volatile, delay, etc.) foo__ - Derefable in a derefable (e.g. delay in an atom), etc. _ - Unnamed val _foo - Named but unused val ?foo - Optional val (emphasize that val may be nil) foo* - A variation of foo (e.g. foo* macro vs foo fn) foo' - '' -foo - Public implementation detail or intermediate (e.g. uncoerced) val

foo - Val "to foo" (e.g. >sender, >host), or fn to put/coerce/transform <foo - Val "from foo" (e.g. <sender, <host), or fn to take/coerce/transform ->foo - Fn to put/coerce/transform

Type affixes may be used for clarity: <prefix>-<name> - m-users, v-users, n-users, etc. (also nusers when unambiguous) <name>-<postfix> - users-map, users-vec, user-count, etc.

Regarding name heirarchy: When there's a significant num of syms with a meaningful hierarchy, prefer names with descending hierarchy to emphasize structure and related groups/functionality, e.g.: user-add, user-remove, user-mod vs add-user, remove-user, mod-user, etc.

Commit message tags (in priority order): ~ - Work-in-progress (still under development) [mod] - Modify behaviour (=> breaking), [mod!], [mod!!], etc. for attention [fix] - Fix broken behaviour (=> usu. non-breaking) [new] - Add new behaviour (=> non-breaking) [nop] - Unmodified behaviour (=> non-breaking implementation or non-code changes, etc.) [x][y] - Single commit with multiple tags (in priority order), try avoid

Example commit messages: v1.0.0 (2022-01-27) ; Tagged release [new] [#122] Add new feature x (@contributor)

Version numbers: Ver tables: X.Y.Z (without backticks) Min ver: vX.Y.Z+ Elsewhere: vX.Y.Z

Extended core library for Clojure/Script that emphasizes:
  * Cross platform API compatibility
  * Flexibility
  * Performance
  * Backwards compatibility

This lib's mostly for my own use and for advanced users that feel
comfortable reading this source. Not providing much beginner-oriented
documentation for this, sorry.

Quick Taoensso naming conventions:
  **foo** - Dynamic var
  foo!    - Fn with side effects, or that should otherwise be used cautiously
  foo?    - Truthy val or fn that returns truthy val
  foo!?   - Fn that has side effects (or requires caution) and that return
            a truthy val. Note: !?, not ?!
  foo$    - Fn that's notably expensive to compute (e.g. hits db)
  foo_    - Derefable val (e.g. atom, volatile, delay, etc.)
  foo__   - Derefable in a derefable (e.g. delay in an atom), etc.
  _       - Unnamed val
  _foo    - Named but unused val
  ?foo    - Optional val (emphasize that val may be nil)
  foo*    - A variation of `foo` (e.g. `foo*` macro vs `foo` fn)
  foo'    - ''
  -foo    - Public implementation detail or intermediate (e.g. uncoerced) val
  >foo    - Val "to   foo" (e.g. >sender, >host), or fn to  put/coerce/transform
  <foo    - Val "from foo" (e.g. <sender, <host), or fn to take/coerce/transform
  ->foo   - Fn to put/coerce/transform

Type affixes may be used for clarity:
  <prefix>-<name>  - m-users,   v-users,   n-users,    etc. (also nusers when unambiguous)
  <name>-<postfix> - users-map, users-vec, user-count, etc.

Regarding name heirarchy:
  When there's a significant num of syms with a meaningful hierarchy,
  prefer names with descending hierarchy to emphasize structure and
  related groups/functionality, e.g.:
    `user-add`, `user-remove`, `user-mod` vs
    `add-user`, `remove-user`, `mod-user`, etc.

Commit message tags (in priority order):
  ~      - Work-in-progress (still under development)
  [mod]  - Modify     behaviour (=>          breaking), [mod!], [mod!!], etc. for attention
  [fix]  - Fix broken behaviour (=> usu. non-breaking)
  [new]  - Add new    behaviour (=>      non-breaking)
  [nop]  - Unmodified behaviour (=>      non-breaking implementation or non-code changes, etc.)
  [x][y] - Single commit with multiple tags (in priority order), try avoid

Example commit messages:
  v1.0.0 (2022-01-27) ; Tagged release
  [new] [#122] Add new feature x (@contributor)

Version numbers:
  Ver tables:  X.Y.Z (without backticks)
     Min ver: vX.Y.Z+
   Elsewhere: vX.Y.Z
raw docstring

*log-level*cljs

DEPRECATED

DEPRECATED
raw docstring

->?singletonclj/s

(->?singleton coll)

->vecclj/s

(->vec x)

(-alias-link-var dst-var src-var dst-attrs)

-as-throwclj/s

(-as-throw kind x)

-assert-unstub-valclj/s≠

clj
(-assert-unstub-val s)
cljs
(-assert-unstub-val f)

-condclj/smacro

(-cond throw? & clauses)

-if-cas!clj/smacro

(-if-cas! atom_ old-val new-val then & [?else])

Micro optimization, mostly for cljs.

Micro optimization, mostly for cljs.
raw docstring

-intern-stubclj/smacro

(-intern-stub ns stub-sym stub-var src)

-matching-errorclj/s

(-matching-error err)
(-matching-error c err)
(-matching-error c pattern err)

-merge-withclj/s

(-merge-with nest? f maps)

-new-stubfn_cljs

(-new-stubfn_ name)

-ring-merge-headersclj

(-ring-merge-headers h1 h2)

Experimental.

Experimental.
raw docstring

-swap-cache!clj/s


-swap-k!clj/s


-swap-val!clj/s

(-swap-val! atom_ k f)

Used internally by memoization utils.

Used internally by memoization utils.
raw docstring

-unswappedclj/s


-vol!clj/smacro

(-vol! val)

-vol-reset!clj/smacro

(-vol-reset! vol_ val)

-vol-swap!clj/smacro

(-vol-swap! vol_ f & args)

-vswappedclj/s


<*clj/smacro

(<* x y z)

<=*clj/smacro

(<=* x y z)

>*clj/smacro

(>* x y z)

>=*clj/smacro

(>=* x y z)

?substr<idxclj/s


?substr<lenclj/s


?subvec<idxclj/s


?subvec<lenclj/s


a0-memoize_clj/s


a1-memoize_clj/s


absclj/s

(abs n)

after-timeoutclj/smacro

(after-timeout msecs & body)

Alpha, subject to change. Returns a TimeoutFuture that will execute body after timeout. Body must be non-blocking or cheap.

Alpha, subject to change.
Returns a TimeoutFuture that will execute body after timeout.
Body must be non-blocking or cheap.
raw docstring

ajax-litecljs

(ajax-lite uri
           {:as opts
            :keys [method params headers timeout-ms resp-type with-credentials?
                   xhr-pool xhr-cb-fn xhr-timeout-ms]
            :or {method :get
                 timeout-ms 10000
                 resp-type :auto
                 xhr-pool default-xhr-pool_
                 xhr-timeout-ms 2500}}
           callback-fn)

Alpha, subject to change. Simple, lightweight Ajax via Google Closure.

Returns nil, or resulting goog.net.XhrIo instance if one was immediately available.

(ajax-lite "/my-post-route" {:method :post :params {:username "Rich Hickey" :type "Awesome"} :headers {"Foo" "Bar"} :resp-type :text :timeout-ms 7000 :with-credentials? false ; Enable if using CORS (requires xhr v2+)

:xhr-pool my-xhr-pool ; goog.net.XhrIoPool instance or delay :xhr-cb-fn (fn [xhr]) ; Called with XhrIo from pool when available :xhr-timeout-ms 2500 ; Max msecs to wait on pool for XhrIo } (fn async-callback-fn [resp-map] (let [{:keys [success? ?status ?error ?content ?content-type]} resp-map] ;; ?status ; ∈ #{nil 200 404 ...}, non-nil iff server responded ;; ?error ; ∈ #{nil <http-error-status-code> <exception> :timeout :abort :http-error :exception :xhr-pool-depleted} (js/alert (str "Ajax response: " resp-map)))))

Alpha, subject to change.
Simple, lightweight Ajax via Google Closure.

Returns nil, or resulting `goog.net.XhrIo` instance if one was
immediately available.

(ajax-lite "/my-post-route"
  {:method     :post
   :params     {:username "Rich Hickey" :type "Awesome"}
   :headers    {"Foo" "Bar"}
   :resp-type  :text
   :timeout-ms 7000
   :with-credentials? false ; Enable if using CORS (requires xhr v2+)

   :xhr-pool       my-xhr-pool ; `goog.net.XhrIoPool` instance or delay
   :xhr-cb-fn      (fn [xhr])  ; Called with `XhrIo` from pool when available
   :xhr-timeout-ms 2500        ; Max msecs to wait on pool for `XhrIo`
  }
  (fn async-callback-fn [resp-map]
    (let [{:keys [success? ?status ?error ?content ?content-type]} resp-map]
      ;; ?status ; ∈ #{nil 200 404 ...}, non-nil iff server responded
      ;; ?error  ; ∈ #{nil <http-error-status-code> <exception> :timeout
                       :abort :http-error :exception :xhr-pool-depleted}
      (js/alert (str "Ajax response: " resp-map)))))
raw docstring

approx=clj/s

(approx= x y)
(approx= x y signf)

approx==clj/s

(approx== x y)
(approx== signf x y)

as-?boolclj/s

(as-?bool x)

as-?emailclj/s

(as-?email ?s)
(as-?email max-len ?s)

as-?floatclj/s

(as-?float x)

as-?intclj/s

(as-?int x)

as-?kwclj/s

(as-?kw x)

as-?nameclj/s

(as-?name x)

as-?nat-floatclj/s

(as-?nat-float x)

as-?nat-intclj/s

(as-?nat-int x)

as-?nblankclj/s

(as-?nblank x)

as-?nblank-trimclj/s

(as-?nblank-trim x)

as-?nemailclj/s

(as-?nemail ?s)
(as-?nemail max-len ?s)

as-?nempty-strclj/s

(as-?nempty-str x)

as-?nzeroclj/s

(as-?nzero x)

as-?pfloatclj/s


as-?pintclj/s


as-?pnumclj/s

(as-?pnum x)

as-?pos-floatclj/s

(as-?pos-float x)

as-?pos-intclj/s

(as-?pos-int x)

as-?pvalclj/s


as-?qnameclj/s

(as-?qname x)

as-?rnumclj/s

(as-?rnum x)

as-?udtclj/s

(as-?udt x)

as-?ufloatclj/s


as-?uintclj/s


as-boolclj/s

(as-bool x)

as-emailclj/s

(as-email x)
(as-email n x)

as-floatclj/s

(as-float x)

as-intclj/s

(as-int x)

as-kwclj/s

(as-kw x)

as-mapclj/s

(as-map kvs & [kf vf])

Deprecated, prefer reduce-kvs

Deprecated, prefer `reduce-kvs`
raw docstring

as-nameclj/s

(as-name x)

as-nat-floatclj/s

(as-nat-float x)

as-nat-intclj/s

(as-nat-int x)

as-nblankclj/s

(as-nblank x)

as-nblank-trimclj/s

(as-nblank-trim x)

as-nemailclj/s

(as-nemail x)
(as-nemail n x)

as-nempty-strclj/s

(as-nempty-str x)

as-nzeroclj/s

(as-nzero x)

as-pfloatclj/s


as-pintclj/s


as-pnumclj/s

(as-pnum x)

as-pnum!clj/s

(as-pnum! x)

as-pnum-complementclj/s

(as-pnum-complement x)

as-pos-floatclj/s

(as-pos-float x)

as-pos-intclj/s

(as-pos-int x)

as-pvalclj/s


as-qnameclj/s

(as-qname x)

as-rnumclj/s

(as-rnum x)

as-rnum!clj/s

(as-rnum! x)

as-udtclj/s

(as-udt x)

as-ufloatclj/s


as-uintclj/s


assert-min-encore-versionclj/s

(assert-min-encore-version min-version)

Version check for dependency conflicts, etc.

Version check for dependency conflicts, etc.
raw docstring

assoc-nxclj/s

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

Assocs each kv iff its key doesn't already exist.

Assocs each kv iff its key doesn't already exist.
raw docstring

assoc-someclj/s

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

Assocs each kv iff its value is not nil.

Assocs each kv iff its value is not nil.
raw docstring

assoc-whenclj/s

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

Assocs each kv iff its val is truthy.

Assocs each kv iff its val is truthy.
raw docstring

atom?clj/s

(atom? x)

ba->hex-strclj

(ba->hex-str ba)

Returns byte[] for given hex string.

Returns byte[] for given hex string.
raw docstring

ba-concatclj

(ba-concat ba1 ba2)

ba-hashclj

(ba-hash x)

ba-splitclj

(ba-split ba idx)

ba=clj

(ba= x y)

backport-run!clj/s


benchclj/smacro

(bench nlaps opts & body)

bench*clj

(bench* nlaps
        {:keys [nlaps-warmup nthreads as-ns?] :or {nlaps-warmup 0 nthreads 1}}
        f)

Repeatedly executes fn and returns time taken to complete execution.

Repeatedly executes fn and returns time taken to complete execution.
raw docstring

boolean?clj/s

(boolean? x)

bytes-classclj


bytes?clj

(bytes? x)

cacheclj/s

(cache f)
(cache {:keys [size ttl-ms gc-every] :as opts} f)

Returns a cached version of given referentially transparent function f.

Like core/memoize but:

  • Often faster, depending on options.

  • Prevents race conditions on writes.

  • Supports cache invalidation by prepending args with:

    • :mem/del ; Delete cached item for subsequent args, returns nil.
    • :mem/fresh ; Renew cached item for subsequent args, returns new val.
  • Supports options:

    • ttl-ms ; Expire cached items after <this> many msecs.

    • size ; Restrict cache size to <this> many items at the next garbage ; collection (GC).

    • gc-every ; Run garbage collection (GC) approximately once every ; <this> many calls to cached fn. If unspecified, GC rate ; will be determined automatically based on size.

See also defn-cached, fmemoize, memoize-last.

Returns a cached version of given referentially transparent function `f`.

Like `core/memoize` but:
  - Often faster, depending on options.
  - Prevents race conditions on writes.
  - Supports cache invalidation by prepending args with:
    - `:mem/del`   ; Delete cached item for subsequent args, returns nil.
    - `:mem/fresh` ; Renew  cached item for subsequent args, returns new val.

  - Supports options:
    - `ttl-ms` ; Expire cached items after <this> many msecs.
    - `size`   ; Restrict cache size to <this> many items at the next garbage
               ; collection (GC).

    - `gc-every` ; Run garbage collection (GC) approximately once every
                 ; <this> many calls to cached fn. If unspecified, GC rate
                 ; will be determined automatically based on `size`.

See also `defn-cached`, `fmemoize`, `memoize-last`.
raw docstring

call-after-timeoutclj/s

(call-after-timeout msecs f)
(call-after-timeout impl_ msecs f)

Alpha, subject to change. Returns a TimeoutFuture that will execute f after given msecs.

Does NOT do any automatic binding conveyance.

Performance depends on the provided timer implementation (impl_). The default implementation offers O(logn) add, O(1) cancel, O(1) tick.

See ITimeoutImpl for extending to arbitrary timer implementations.

Alpha, subject to change.
Returns a TimeoutFuture that will execute `f` after given msecs.

Does NOT do any automatic binding conveyance.

Performance depends on the provided timer implementation (`impl_`).
The default implementation offers O(logn) add, O(1) cancel, O(1) tick.

See `ITimeoutImpl` for extending to arbitrary timer implementations.
raw docstring

can-meta?clj/s

(can-meta? x)

case-evalclj/smacro

(case-eval expr & clauses)

Like case but evals test constants for their compile-time value.

Like `case` but evals test constants for their compile-time value.
raw docstring

case-insensitive-str=clj/s

(case-insensitive-str= s1 s2)

Returns true iff given strings are equal, ignoring case.

Returns true iff given strings are equal, ignoring case.
raw docstring

catch-errorsclj/smacro

(catch-errors & body)

catch-errors*clj/smacro

(catch-errors* & args)

catchingclj/smacro

(catching try-expr)
(catching try-expr error-sym catch-expr)
(catching try-expr error-sym catch-expr finally-expr)
(catching try-expr error-type error-sym catch-expr finally-expr)

Cross-platform try/catch/finally.

Cross-platform try/catch/finally.
raw docstring

catching-rfclj/s

(catching-rf rf)
(catching-rf error-fn rf)

Returns wrapper around given reducing function rf so that if rf throws, (error-fn <thrown-error> <contextual-data>) will be called.

The default error-fn will rethrow the original error, wrapped in extra contextual information to aid debugging.

See also catching-xform.

Returns wrapper around given reducing function `rf` so that if `rf`
throws, (error-fn <thrown-error> <contextual-data>) will be called.

The default `error-fn` will rethrow the original error, wrapped in
extra contextual information to aid debugging.

See also `catching-xform`.
raw docstring

catching-xformclj/s

(catching-xform xform)
(catching-xform error-fn xform)

Like catching-rf, but applies to a transducer (xform).

Makes debugging transductions much easier by greatly improving the information provided in any errors thrown by xform or the reducing fn:

(transduce (catching-xform (comp (filter even?) (map inc))) ; Modified xform <reducing-fn> <...>)

Like `catching-rf`, but applies to a transducer (`xform`).

Makes debugging transductions much easier by greatly improving
the information provided in any errors thrown by `xform` or the
reducing fn:

  (transduce
    (catching-xform (comp (filter even?) (map inc))) ; Modified xform
    <reducing-fn>
    <...>)
raw docstring

caught-error-dataclj/smacro

(caught-error-data & body)

Handy for error-throwing unit tests.

Handy for error-throwing unit tests.
raw docstring

chan?clj/s

(chan? x)

chanceclj/s

(chance p)

check-allclj/smacro

(check-all test)
(check-all test & more)

Returns all logical false/throwing expressions (ids/forms), or nil.

Returns all logical false/throwing expressions (ids/forms), or nil.
raw docstring

check-someclj/smacro

(check-some test)
(check-some test & more)

Returns first logical false/throwing expression (id/form), or nil.

Returns first logical false/throwing expression (id/form), or nil.
raw docstring

clampclj/s

(clamp nmin nmax n)

clamp*clj/smacro

(clamp* nmin nmax n)

clamp-floatclj/s

(clamp-float nmin nmax n)

clamp-intclj/s

(clamp-int nmin nmax n)

clj1098clj/s

(clj1098 x)
Ref. http://goo.gl/0GzRuz
raw docstring

compile-ifclj/smacro

(compile-if test then)
(compile-if test then else)

Evaluates test. If it returns logical true (and doesn't throw), expands to then, otherwise expands to else.

Evaluates `test`. If it returns logical true (and doesn't throw), expands
to `then`, otherwise expands to `else`.
raw docstring

compile-ns-filterclj/s

(compile-ns-filter ns-pattern)
(compile-ns-filter whitelist blacklist)

Deprecated, prefer compile-str-filter instead.

Deprecated, prefer `compile-str-filter` instead.
raw docstring

compile-str-filterclj/s

(compile-str-filter spec)

Compiles given spec and returns a fast (fn conform? [?in-str]).

Spec may be:

  • A regex pattern. Will conform on match.

  • A string, in which any ""s will act as wildcards (#"."). Will conform on match.

  • A vector or set of regex patterns or strings. Will conform on ANY match. If you need literal "*"s, use an explicit regex pattern instead.

  • {:allow <allow-spec> :deny <deny-spec> :cache? <bool>}. Will conform iff allow-spec matches AND deny-spec does NOT.

Input may be: namespace strings, class names, etc. Useful as string allowlist (whitelist) and/or denylist (blacklist).

Spec examples: #{}, "", "foo.bar", "foo.bar.", #{"foo" "bar."}, {:allow #{"foo" "bar."} :deny #{"foo..bar."}}

Compiles given spec and returns a fast (fn conform? [?in-str]).

Spec may be:
  - A regex pattern. Will conform on match.
  - A string, in which any "*"s will act as wildcards (#".*").
    Will conform on match.

  - A vector or set of regex patterns or strings.
    Will conform on ANY match.
    If you need literal "*"s, use an explicit regex pattern instead.

  - {:allow <allow-spec> :deny <deny-spec> :cache? <bool>}.
    Will conform iff allow-spec matches AND deny-spec does NOT.

Input may be: namespace strings, class names, etc.
Useful as string allowlist (whitelist) and/or denylist (blacklist).

Spec examples:
  #{}, "*", "foo.bar", "foo.bar.*", #{"foo" "bar.*"},
  {:allow #{"foo" "bar.*"} :deny #{"foo.*.bar.*"}}
raw docstring

compile-whenclj/smacro

(compile-when test & body)

compiling-cljs?clj

(compiling-cljs?)

Return truthy iff currently generating Cljs code. See also if-cljs, if-clj.

Return truthy iff currently generating Cljs code.
See also `if-cljs`, `if-clj`.
raw docstring

condclj/smacro

(cond & clauses)

Like core/cond but supports implicit final else clause, and special clause keywords for advanced behaviour:

(cond :let [x "x"] ; Establish let binding/s for remaining forms :binding [x "x"] ; Establish dynamic binding/s for remaining forms :do (println (str "x value: " x)) ; Eval expr for side effects

:if-let [y "y" z nil] "y and z were both truthy"

:if-some [y "y" z nil] "y and z were both non-nil")

:let support inspired by https://github.com/Engelberg/better-cond. Simple, flexible way to eliminate deeply-nested control flow code.

Like `core/cond` but supports implicit final `else` clause, and special
clause keywords for advanced behaviour:

(cond
  :let     [x   "x"] ; Establish let     binding/s for remaining forms
  :binding [*x* "x"] ; Establish dynamic binding/s for remaining forms
  :do      (println (str "x value: " x)) ; Eval expr for side effects

  :if-let [y "y"
           z nil]
  "y and z were both truthy"

  :if-some [y "y"
            z nil]
  "y and z were both non-nil")

:let support inspired by https://github.com/Engelberg/better-cond.
Simple, flexible way to eliminate deeply-nested control flow code.
raw docstring

cond!clj/smacro

(cond! & clauses)

Like cond but throws on non-match like case and condp.

Like `cond` but throws on non-match like `case` and `condp`.
raw docstring

cond*clj/smacro

(cond* & args)

cond-throwclj/smacro

(cond-throw & args)

conj-someclj/s

(conj-some)
(conj-some coll)
(conj-some coll x)
(conj-some coll x & more)

Conjoins each non-nil value.

Conjoins each non-nil value.
raw docstring

conj-whenclj/s

(conj-when)
(conj-when coll)
(conj-when coll x)
(conj-when coll x & more)

Conjoins each truthy value.

Conjoins each truthy value.
raw docstring

const-ba=clj

(const-ba= ba1 ba2)

Constant-time ba=. Useful to prevent timing attacks, etc.

Constant-time `ba=`.
Useful to prevent timing attacks, etc.
raw docstring

const-str=clj/s

(const-str= s1 s2)

Constant-time string equality checker. Useful to prevent timing attacks, etc.

Constant-time string equality checker.
Useful to prevent timing attacks, etc.
raw docstring

contains-in?clj/s

(contains-in? coll ks)
(contains-in? coll ks k)

convey-reducedclj/s

(convey-reduced x)

count-wordsclj/s

(count-words s)

counterclj/s

(counter)
(counter init)

Returns a fast atomic Counter with init initial int value:

  • (<counter> ) -> add 1, return old val
  • (<counter> <n>) -> add n, return old val

Experimental 3-arity version takes an action: :add, :set, :set-get, :get-set, :get-add, :add-get

Returns a fast atomic Counter with `init` initial int value:
- (<counter>    ) -> add 1, return old val
- (<counter> <n>) -> add n, return old val

Experimental 3-arity version takes an `action`:
  :add, :set, :set-get, :get-set, :get-add, :add-get
raw docstring

debugfcljs

(debugf fmt & xs)

declare-remoteclj/smacro

(declare-remote & syms)

Declares given ns-qualified symbols, preserving metadata. Useful for circular dependencies.

Declares given ns-qualified symbols, preserving metadata. Useful for
circular dependencies.
raw docstring

defaliasclj/smacro

(defalias src-sym)
(defalias alias-sym src-sym)
(defalias alias-sym src-sym alias-attrs)

Defines a local alias for the var identified by the given qualified source symbol: (defalias my-map clojure.core/map), etc.

For Clj:

  • Source var's metadata will be preserved (docstring, arglists, etc.).
  • Changes to source var's value will also be applied to alias.
Defines a local alias for the var identified by the given qualified
source symbol: (defalias my-map clojure.core/map), etc.

For Clj:
  - Source var's metadata will be preserved (docstring, arglists, etc.).
  - Changes to source var's value will also be applied to alias.
raw docstring

defaliasesclj/smacro

(defaliases & aliases)

Bulk version of defalias. Takes source symbols or {:keys [alias src attrs]} maps: (defaliases {:alias my-map, :src map, :attrs {:doc "My map alias"}} {:alias my-vec, :src vec, :attrs {:doc "My vec alias"}})

Bulk version of `defalias`.
Takes source symbols or {:keys [alias src attrs]} maps:
  (defaliases
    {:alias my-map, :src map, :attrs {:doc "My `map` alias"}}
    {:alias my-vec, :src vec, :attrs {:doc "My `vec` alias"}})
raw docstring

default-timeout-impl_clj/s

Simple one-timeout timeout implementation provided by platform timer. O(logn) add, O(1) cancel, O(1) tick. Fns must be non-blocking or cheap. Similar efficiency to core.async timers (binary heap vs DelayQueue).

Simple one-timeout timeout implementation provided by platform timer.
O(logn) add, O(1) cancel, O(1) tick. Fns must be non-blocking or cheap.
Similar efficiency to core.async timers (binary heap vs DelayQueue).
raw docstring

defn-cachedclj/smacro

(defn-cached sym cache-opts & body)

Defines a cached function. Like (def <sym> (cache <cache-opts> <body...>)), but preserves :arglists (arity) metadata as with defn:

(defn-cached ^:private my-fn {:ttl-ms 500} "Does something interesting, caches resultes for 500 msecs" [n] (rand-int n))

Defines a cached function.
Like (def <sym> (cache <cache-opts> <body...>)), but preserves
:arglists (arity) metadata as with `defn`:

  (defn-cached ^:private my-fn {:ttl-ms 500}
    "Does something interesting, caches resultes for 500 msecs"
    [n]
    (rand-int n))
raw docstring

defonceclj/smacro

(defonce sym & args)

Like core/defonce but supports optional docstring and attrs map.

Like `core/defonce` but supports optional docstring and attrs map.
raw docstring

defonce*clj/smacro

(defonce* & args)

defstubclj/smacro

(defstub sym)

Experimental. Declares a stub var that can be initialized from any namespace with unstub-<stub-name>. Decouples a var's declaration (location) and its initialization (value). Handy for defining vars in a shared ns from elsewhere (e.g. a private or cyclic ns).

Experimental. Declares a stub var that can be initialized from any
namespace with `unstub-<stub-name>`. Decouples a var's declaration
(location) and its initialization (value). Handy for defining vars in a
shared ns from elsewhere (e.g. a private or cyclic ns).
raw docstring

deftype-print-methodsclj/smacro

(deftype-print-methods & types)

Private, used by other Taoensso libs.

Private, used by other Taoensso libs.
raw docstring

deprecatedclj/smacro

(deprecated & body)

Elides body when taoensso.elide-deprecated JVM property or TAOENSSO_ELIDE_DEPRECATED environment variable is ∈ #{"true" "TRUE"}.

Elides body when `taoensso.elide-deprecated` JVM property or
`TAOENSSO_ELIDE_DEPRECATED` environment variable is ∈ #{"true" "TRUE"}.
raw docstring

derefable?clj/s

(derefable? x)

dis-assoc-someclj/s

(dis-assoc-some m kvs)
(dis-assoc-some m k v)
(dis-assoc-some m k v & kvs)

Assocs each kv if its value is not nil, otherwise dissocs it.

Assocs each kv if its value is not nil, otherwise dissocs it.
raw docstring

dissoc-inclj/s

(dissoc-in m ks)
(dissoc-in m ks dissoc-k)
(dissoc-in m ks dissoc-k & more)

distinct-byclj/s

(distinct-by keyfn coll)

Deprecated, prefer xdistinct

Deprecated, prefer `xdistinct`
raw docstring

distinct-elements?clj/s

(distinct-elements? x)

distinctvclj/s

(distinctv coll)
(distinctv keyfn coll)

Deprecated, prefer xdistinct

Deprecated, prefer `xdistinct`
raw docstring

do-falseclj/smacro

(do-false & body)

do-nilclj/smacro

(do-nil & body)

do-trueclj/smacro

(do-true & body)

doto-condclj/smacro

(doto-cond [sym x] & clauses)

Cross between doto, cond-> and as->.

Cross between `doto`, `cond->` and `as->`.
raw docstring

dswap!clj/s


editable?clj/s

(editable? x)

encore-versionclj/s


ensure-setclj/s

(ensure-set x)

ensure-vecclj/s

(ensure-vec x)

error-dataclj/s

(error-data x)

Returns data map iff x is an error of any type on platform.

Returns data map iff `x` is an error of any type on platform.
raw docstring

error?clj/s

(error? x)

errorfcljs

(errorf fmt & xs)

everyclj/s


ex-causeclj/s

(ex-cause ex)

Copy of core/ex-cause (added in Clojure v1.10)

Copy of `core/ex-cause` (added in Clojure v1.10)
raw docstring

ex-messageclj/s

(ex-message ex)

Copy of core/ex-message (added in Clojure v1.10)

Copy of `core/ex-message` (added in Clojure v1.10)
raw docstring

exception?clj

(exception? x)

exp-backoffclj/s

(exp-backoff n-attempt)
(exp-backoff n-attempt {:keys [min max factor] :or {factor 1000}})

Returns binary exponential backoff value for n<=36.

Returns binary exponential backoff value for n<=36.
raw docstring

explode-keywordclj/s

(explode-keyword k)

fatalfcljs

(fatalf fmt & xs)

file-resources-modified?clj

Returns true iff any files backing the given named resources have changed since last call.

Returns true iff any files backing the given named resources have changed
since last call.
raw docstring

filter-keysclj/s

(filter-keys pred m)

filter-kvsclj/s

(filter-kvs pred m)

filter-valsclj/s

(filter-vals pred m)

finite-num?clj/s

(finite-num? x)

Returns true iff given a number (of standard type) that is: finite (excl. NaN and infinities).

Returns true iff given a number (of standard type) that is:
finite (excl. NaN and infinities).
raw docstring

float?clj/s

(float? x)

Returns true iff given a number (of standard type) that is: a fixed-precision floating-point (incl. NaN and infinities).

Returns true iff given a number (of standard type) that is:
a fixed-precision floating-point (incl. NaN and infinities).
raw docstring

fmemoizeclj/s

(fmemoize f)

For Clj: fastest possible memoize. Non-racey, 0-3 arity only. For Cljs: just passes through to core/memoize.

For Clj: fastest possible memoize. Non-racey, 0-3 arity only.
For Cljs: just passes through to `core/memoize`.
raw docstring

force-refclj/s

(force-ref x)

Like force for refs.

Like `force` for refs.
raw docstring

force-varclj/s

(force-var x)

Like force for vars.

Like `force` for vars.
raw docstring

formatclj/s

(format fmt & args)

Like core/format but:

  • Returns "" when fmt is nil rather than throwing an NPE.
  • Formats nil as "nil" rather than "null".
  • Provides ClojureScript support via goog.string.format (this has fewer formatting options than Clojure's format!).
Like `core/format` but:
* Returns "" when fmt is nil rather than throwing an NPE.
* Formats nil as "nil" rather than "null".
* Provides ClojureScript support via goog.string.format (this has fewer
  formatting options than Clojure's `format`!).
raw docstring

format*clj/s

(format* fmt args)
(format* xform fmt args)

format-query-stringclj/s

(format-query-string m)

fq-nameclj/s


future-poolclj

(future-pool n-threads)

Returns a simple semaphore-limited wrapper of Clojure's standard future: (fn [f] - Blocks to acquire a future, then executes (f) on that future. [ ] - Blocks to acquire all futures, then immediately releases them. Useful for blocking till all outstanding work completes. Timeout variants are also provided.

Returns a simple semaphore-limited wrapper of Clojure's standard `future`:
  (fn
    [f] - Blocks to acquire a future, then executes (f) on that future.
    [ ] - Blocks to acquire all futures, then immediately releases them.
          Useful for blocking till all outstanding work completes.
Timeout variants are also provided.
raw docstring

fzipmapclj/s

(fzipmap ks vs)

get-dynamic-assertion-datacljdeprecated

(get-dynamic-assertion-data)

Prefer get-data

Prefer `get-data`
raw docstring

get-envclj/smacro

(get-env)

get-file-resource-?last-modifiedclj

(get-file-resource-?last-modified rname)

Returns last-modified time for file backing given named resource, or nil if file doesn't exist.

Returns last-modified time for file backing given named resource, or nil
if file doesn't exist.
raw docstring

get-hostnameclj

(get-hostname)

Returns local hostname string, or nil.

Returns local hostname string, or nil.
raw docstring

get-pom-versionclj

(get-pom-version dep-sym)

Returns POM version string for given Maven dependency, or nil.

Returns POM version string for given Maven dependency, or nil.
raw docstring

get-sourceclj

(get-source form env)

Returns {:keys [ns line column file]} callsite and file info given a macro's compile-time &form and &env vals. See also keep-callsite.

Returns {:keys [ns line column file]} callsite and file info given a
macro's compile-time `&form` and `&env` vals. See also `keep-callsite`.
raw docstring

get-substrclj/sdeprecated

(get-substr s start)
(get-substr s start end)

Prefer get-substr-by-idx

Prefer `get-substr-by-idx`
raw docstring

get-substr-by-idxclj/s

(get-substr-by-idx s start-idx)
(get-substr-by-idx s start-idx end-idx)

Returns ?substring from given string.

Like subs but:

  • Provides consistent clj/s behaviour.
  • Never throws (snaps to valid indexes).
  • Indexes may be -ive (=> indexed from end of string).

Returns nil when requested substring would be empty.

Returns ?substring from given string.

Like `subs` but:
  - Provides consistent clj/s behaviour.
  - Never throws (snaps to valid indexes).
  - Indexes may be -ive (=> indexed from end of string).

Returns nil when requested substring would be empty.
raw docstring

get-substr-by-lenclj/s

(get-substr-by-len s start-idx)
(get-substr-by-len s start-idx sub-len)

Returns ?substring from given string. Like get-substr-by-idx, but takes a substring-length 3rd argument.

Returns ?substring from given string.
Like `get-substr-by-idx`, but takes a substring-length 3rd argument.
raw docstring

get-substringclj/sdeprecated

(get-substring s start)
(get-substring s start length)

Prefer get-substr-by-len

Prefer `get-substr-by-len`
raw docstring

get-subvecclj/s

(get-subvec v start)
(get-subvec v start end)

Like subvec but never throws (snaps to valid start and end indexes).

Like `subvec` but never throws (snaps to valid start and end indexes).
raw docstring

get-subvectorclj/s

(get-subvector v start)
(get-subvector v start length)

Like get-subvec but:

  • Takes length instead of end (index).
  • -ive start => index from right of vector.
Like `get-subvec` but:
- Takes `length` instead of `end` (index).
- -ive `start` => index from right of vector.
raw docstring

get-sys-boolclj

(get-sys-bool default prop-id env-id)

If prop-id JVM property or env-id environment variable are set:

  • Returns true if set value is ∈ #{"true" "1" "t" "T" "TRUE"}
  • Returns false if set value is ∈ #{"false" "0" "f" "F" "FALSE"}
  • Otherwise throws

Returns default if neither property nor environment variable is set.

If `prop-id` JVM property or `env-id` environment variable are set:
  - Returns `true`  if set value is ∈ #{"true"  "1" "t" "T" "TRUE"}
  - Returns `false` if set value is ∈ #{"false" "0" "f" "F" "FALSE"}
  - Otherwise throws

Returns `default` if neither property nor environment variable is set.
raw docstring

get-sys-valclj

(get-sys-val id)
(get-sys-val prop-id env-id)

get-truss-dataclj/s≠

clj
(get-truss-data)

Returns current value of dynamic assertion data.

Returns current value of dynamic assertion data.
cljs
raw docstring

get-win-loccljs

(get-win-loc)

Returns js/window's current location as a map.

Returns `js/window`'s current location as a map.
raw docstring

get-window-locationcljs


greatestclj/s

(greatest coll & [?comparator])

haveclj/smacro

(have x)
(have pred (:in) x)
(have pred (:in) x & more-xs)

Takes a pred and one or more vals. Tests pred against each val, trapping errors. If any pred test fails, throws a detailed assertion error. Otherwise returns input val/vals for convenient inline-use/binding.

Respects assert value so tests can be elided from production for zero runtime costs.

Provides a small, simple, flexible feature subset to alternative tools like clojure.spec, core.typed, prismatic/schema, etc.

;; Will throw a detailed error message on invariant violation: (fn my-fn [x] (str/trim (have string? x)))

You may attach arbitrary debug info to assertion violations like: (have string? x :data {:my-arbitrary-debug-info "foo"})

Re: use of Truss assertions within other macro bodies: Due to CLJ-865, call site information (e.g. line number) of outer macro will unfortunately be lost.

See keep-callsite util for a workaround.

See also have?, have!.

Takes a pred and one or more vals. Tests pred against each val,
trapping errors. If any pred test fails, throws a detailed assertion error.
Otherwise returns input val/vals for convenient inline-use/binding.

Respects *assert* value so tests can be elided from production for zero
runtime costs.

Provides a small, simple, flexible feature subset to alternative tools like
clojure.spec, core.typed, prismatic/schema, etc.

  ;; Will throw a detailed error message on invariant violation:
  (fn my-fn [x] (str/trim (have string? x)))

You may attach arbitrary debug info to assertion violations like:
  `(have string? x :data {:my-arbitrary-debug-info "foo"})`

Re: use of Truss assertions within other macro bodies:
  Due to CLJ-865, call site information (e.g. line number) of
  outer macro will unfortunately be lost.

  See `keep-callsite` util for a workaround.

See also `have?`, `have!`.
raw docstring

have!clj/smacro

(have! x)
(have! pred (:in) x)
(have! pred (:in) x & more-xs)

Like have but ignores assert value (so can never be elided). Useful for important conditions in production (e.g. security checks).

Like `have` but ignores *assert* value (so can never be elided). Useful
for important conditions in production (e.g. security checks).
raw docstring

have!?clj/smacro

(have!? x)
(have!? pred (:in) x)
(have!? pred (:in) x & more-xs)

Specialized cross between have? and have!. Not used often but can be handy for semantic clarification and/or to improve multi-val performance when the return vals aren't necessary.

WARNING: Do NOT use in :pre/:post conds since those are ALWAYS subject to assert, directly contradicting the intention of the bang (!) here.

Specialized cross between `have?` and `have!`. Not used often but can be
handy for semantic clarification and/or to improve multi-val performance
when the return vals aren't necessary.

**WARNING**: Do NOT use in :pre/:post conds since those are ALWAYS subject
to *assert*, directly contradicting the intention of the bang (`!`) here.
raw docstring

have-core-async?clj


have-inclj/smacro

(have-in a1 & an)

have-in!clj/smacro

(have-in! a1 & an)

have-transducers?clj/s


have?clj/smacro

(have? x)
(have? pred (:in) x)
(have? pred (:in) x & more-xs)

Like have but returns true on successful tests. In particular, this can be handy for use with :pre/:post conditions. Compare: (fn my-fn [x] {:post [(have nil? %)]} nil) ; {:post [nil]} FAILS (fn my-fn [x] {:post [(have? nil? %)]} nil) ; {:post [true]} passes as intended

Like `have` but returns `true` on successful tests. In particular, this
can be handy for use with :pre/:post conditions. Compare:
  (fn my-fn [x] {:post [(have  nil? %)]} nil) ; {:post [nil]} FAILS
  (fn my-fn [x] {:post [(have? nil? %)]} nil) ; {:post [true]} passes as intended
raw docstring

hex-str->baclj

(hex-str->ba s)

Returns hex string for given byte[].

Returns hex string for given byte[].
raw docstring

ident-hex-strclj

(ident-hex-str obj)

Returns hex string of given Object's identityHashCode (e.g. "0x5eeb49f2").

Returns hex string of given Object's `identityHashCode` (e.g. "0x5eeb49f2").
raw docstring

ident?clj/s

(ident? x)

idx-fnclj/s


if-cljclj/smacro

(if-clj then & [else])

if-cljsclj/smacro

(if-cljs then & [else])

if-letclj/smacro

(if-let bindings then)
(if-let bindings then else)

Like core/if-let but can bind multiple values for then iff all tests are truthy, supports internal unconditional :lets.

Like `core/if-let` but can bind multiple values for `then` iff all tests
are truthy, supports internal unconditional `:let`s.
raw docstring

if-letsclj/smacro

(if-lets & args)

if-notclj/smacro

(if-not test-or-bindings then)
(if-not test-or-bindings then else)

Like core/if-not but acts like if-let when given a binding vector as test expr.

Like `core/if-not` but acts like `if-let` when given a binding vector
as test expr.
raw docstring

if-not*clj/smacro

(if-not* & args)

if-someclj/smacro

(if-some bindings then)
(if-some bindings then else)

Like core/if-some but can bind multiple values for then iff all tests are non-nil, supports internal unconditional :lets.

Like `core/if-some` but can bind multiple values for `then` iff all tests
are non-nil, supports internal unconditional `:let`s.
raw docstring

indexed?clj/s

(indexed? x)

infofcljs

(infof fmt & xs)

instance!clj/s

(instance! class arg & {:as details})

If (instance? class arg) is true, returns arg. Otherwise throws runtime ExceptionInfo with unexpected-arg!. See unexpected-arg! for more info.

If (instance? class arg) is true, returns arg.
Otherwise throws runtime `ExceptionInfo` with `unexpected-arg!`.
See `unexpected-arg!` for more info.
raw docstring

int?clj/s

(int? x)

Returns true iff given a number (of standard type) that is: a fixed-precision integer.

Returns true iff given a number (of standard type) that is:
a fixed-precision integer.
raw docstring

interleave-allclj/s

(interleave-all)
(interleave-all c1)
(interleave-all c1 c2)
(interleave-all c1 c2 & colls)

Greedy version of interleave.

Greedy version of `interleave`.
raw docstring

interns-overviewclj

(interns-overview)
(interns-overview ns)

Returns {:keys [public private impl test]}, with each key mapped to an alphabetical list of the relevant vars in given namespace.

"impl" vars are public vars with names that begin with "-" or "_", a naming convention commonly used to indicate vars intended to be treated as private implementation details even when public.

Returns {:keys [public private impl test]}, with each key mapped to
an alphabetical list of the relevant vars in given namespace.

"impl" vars are public vars with names that begin with "-" or "_",
a naming convention commonly used to indicate vars intended to be treated
as private implementation details even when public.
raw docstring

into!clj/s

(into! to from)
(into! to xform from)

into-allclj/s

(into-all to from)
(into-all to from & more)

Like into but supports multiple "from"s.

Like `into` but supports multiple "from"s.
raw docstring

into-strclj/s

(into-str & xs)

Simple Hiccup-like string templating to complement Tempura.

Simple Hiccup-like string templating to complement Tempura.
raw docstring

invert-mapclj/s

(invert-map m)

is!clj/s

(is! x)
(is! pred x)
(is! pred x data)

Lightweight have! that provides less diagnostic info.

Lightweight `have!` that provides less diagnostic info.
raw docstring

ITimeoutFutureclj/sprotocol

tf-cancel!clj/s

(tf-cancel! _)

Returns true iff the timeout was successfully cancelled (i.e. was previously pending).

Returns true iff the timeout was successfully cancelled (i.e. was previously pending).

tf-cancelled?clj/s

(tf-cancelled? _)

Returns true iff the timeout is cancelled.

Returns true iff the timeout is cancelled.

tf-done?clj/s

(tf-done? _)

Returns true iff the timeout is not pending (i.e. has a completed result or is cancelled).

Returns true iff the timeout is not pending (i.e. has a completed result or is cancelled).

tf-pending?clj/s

(tf-pending? _)

Returns true iff the timeout is pending.

Returns true iff the timeout is pending.

tf-pollclj/s

(tf-poll _)

Returns :timeout/pending, :timeout/cancelled, or the timeout's completed result.

Returns :timeout/pending, :timeout/cancelled, or the timeout's completed result.

tf-stateclj/s

(tf-state _)

Returns a map of timeout's public state.

Returns a map of timeout's public state.

ITimeoutImplclj/sprotocol

-schedule-timeoutclj/s

(-schedule-timeout _ msecs f)

join-onceclj/s

(join-once sep & coll)

js-?wincljs


keep-callsiteclj/smacro

(keep-callsite & body)

The long-standing CLJ-865 unfortunately means that it's currently not possible for an inner macro to access the &form metadata of an outer macro.

This means that inner macros lose call site information like the line number of the outer macro.

This util offers a workaround for macro authors:

(defmacro inner [] (meta &form)) (defmacro outer1 [] (inner)) (defmacro outer2 [] (keep-callsite(inner)))

(inner) => {:line _, :column _} (outer1) => nil (outer2) => {:line _, :column _}

The long-standing CLJ-865 unfortunately means that it's currently
not possible for an inner macro to access the &form metadata of an
outer macro.

This means that inner macros lose call site information like the
line number of the outer macro.

This util offers a workaround for macro authors:

  (defmacro inner  [] (meta &form))
  (defmacro outer1 []                `(inner))
  (defmacro outer2 [] (keep-callsite `(inner)))

  (inner)  => {:line _, :column _}
  (outer1) => nil
  (outer2) => {:line _, :column _}
raw docstring

keys-byclj/s

(keys-by f coll)

Returns {(f x) x} map for xs in coll.

Returns {(f x) x} map for xs in `coll`.
raw docstring

keys<=clj/s

(keys<= m ks)

keys=clj/s

(keys= m ks)

keys=nnil?clj/s

(keys=nnil? m ks)

keys>=clj/s

(keys>= m ks)

keywordize-mapclj/s

(keywordize-map m)

ks-nnil?clj/s

(ks-nnil? ks m)

ks<=clj/s

(ks<= ks m)

ks=clj/s

(ks= ks m)

ks>=clj/s

(ks>= ks m)

kw-identical?clj/s


lazy-seq?clj/s

(lazy-seq? x)

leastclj/s

(least coll & [?comparator])

limiterclj/s

(limiter specs)
(limiter opts specs)

Takes {<spec-id> [<n-max-reqs> <msecs-window>]}, and returns a rate limiter (fn check-limits! [req-id]) -> nil (all limits pass), or [<worst-spec-id> <worst-backoff-msecs> {<spec-id> <backoff-msecs>}].

Limiter fn commands: :rl/peek <req-id> - Check limits w/o side effects. :rl/reset <req-id> - Reset all limits for given req-id.

Takes {<spec-id> [<n-max-reqs> <msecs-window>]}, and returns a rate
limiter (fn check-limits! [req-id]) -> nil (all limits pass), or
[<worst-spec-id> <worst-backoff-msecs> {<spec-id> <backoff-msecs>}].

Limiter fn commands:
  :rl/peek  <req-id> - Check limits w/o side effects.
  :rl/reset <req-id> - Reset all limits for given req-id.
raw docstring

limiter*clj/s

(limiter* specs)
(limiter* opts specs)

Experimental. Like limiter but returns [<state_> <limiter>].

Experimental. Like `limiter` but returns [<state_> <limiter>].
raw docstring

load-edn-configclj

(load-edn-config {:as opts
                  :keys [default prop env res auto-env? error-data]
                  :or {auto-env? true}})

Attempts to read config as EDN from the following (in descending order):

  1. JVM property, if opt is provided and value is present.
  2. Env var, if opt is provided and value is present.
  3. Resource file, if opt is provided and resource is present.

Returns nil, or {:config <loaded-config>, :source <source-of-loaded-config>}.

Throws if value/resource cannot be successfully read as EDN. The read EDN value must be a map, or a symbol that resolves to a map.

Useful for libraries, etc. that want to provide easily modified config. Used by Timbre, Carmine, etc.

Options:

  • default ; Default config map into which a nested merge will be done
  • prop ; Name of JVM property to check (e.g. "taoensso.timbre.config.edn")
  • env ; Name of Env var to check (e.g. "TAOENSSO_TIMBRE_CONFIG_EDN")
  • res ; Name of resource file to check (e.g. "taoensso.timbre.config.edn")
  • auto-env? ; If true, env will be provided automatically based on prop
  • error-data ; Optional map to be added to ex-data if load fails
Attempts to read config as EDN from the following (in descending order):
  1. JVM property,   if opt is provided and value    is present.
  2. Env var,        if opt is provided and value    is present.
  3. Resource file,  if opt is provided and resource is present.

Returns nil, or {:config           <loaded-config>,
                 :source <source-of-loaded-config>}.

Throws if value/resource cannot be successfully read as EDN.
The read EDN value must be a map, or a symbol that resolves to a map.

Useful for libraries, etc. that want to provide easily modified config.
Used by Timbre, Carmine, etc.

Options:
  - default    ; Default config map into which a nested merge will be done
  - prop       ; Name of JVM property  to check (e.g. "taoensso.timbre.config.edn")
  - env        ; Name of Env var       to check (e.g. "TAOENSSO_TIMBRE_CONFIG_EDN")
  - res        ; Name of resource file to check (e.g. "taoensso.timbre.config.edn")
  - auto-env?  ; If true, `env` will be provided automatically based on `prop`
  - error-data ; Optional map to be added to ex-data if load fails
raw docstring

logcljs


logfcljs

(logf fmt & xs)

logging-levelclj/s


logpcljs

(logp & xs)

map-keysclj/s

(map-keys f m)

map-kvsclj/s

(map-kvs kf vf m)

Deprecated, prefer reduce-kv

Deprecated, prefer `reduce-kv`
raw docstring

map-valsclj/s

(map-vals f m)

mapplyclj/s

(mapply f & args)

Like apply but calls seq-kvs on final arg.

Like `apply` but calls `seq-kvs` on final arg.
raw docstring

max*clj/smacro

(max* n1 n2)

max-longclj/s


memoizeclj/s

(memoize f)
(memoize ttl-ms f)
(memoize size ttl-ms f)

Alternative way to call cache, provided mostly for back compatibility. See cache docstring for details.

Alternative way to call `cache`, provided mostly for back compatibility.
See `cache` docstring for details.
raw docstring

memoize*clj/s


memoize-1clj/s


memoize-a0_clj/s


memoize-a1_clj/s


memoize-lastclj/s

(memoize-last f)

Like core/memoize but only caches the fn's most recent call. Great for Reactjs render op caching on mobile devices, etc.

Like `core/memoize` but only caches the fn's most recent call.
Great for Reactjs render op caching on mobile devices, etc.
raw docstring

memoize1clj/s


memoize_clj/s


memoizedclj/s

(memoized cache f & args)

mergeclj/s

(merge & maps)

Like core/merge but faster, supports :swap/dissoc rvals.

Like `core/merge` but faster, supports `:swap/dissoc` rvals.
raw docstring

merge-deepclj/s


merge-deep-withclj/s


merge-headersclj

(merge-headers rresp headers)

merge-keywordsclj/s

(merge-keywords ks)
(merge-keywords ks omit-slash?)

merge-metaclj/s

(merge-meta x m)

merge-url-with-query-stringclj/s

(merge-url-with-query-string url m)

merge-withclj/s

(merge-with f & maps)

Like core/merge-with but faster, supports :swap/dissoc rvals.

Like `core/merge-with` but faster, supports `:swap/dissoc` rvals.
raw docstring

min*clj/smacro

(min* n1 n2)

min-longclj/s


msclj/s

(ms & {:as opts :keys [years months weeks days hours mins secs msecs ms]})

Returns ~number of milliseconds in period defined by given args.

Returns ~number of milliseconds in period defined by given args.
raw docstring

ms->secsclj/s

(ms->secs ms)

msecsclj/smacro

(msecs & opts)

Compile-time version of ms

Compile-time version of `ms`
raw docstring

name-with-attrsclj/s

(name-with-attrs sym args)
(name-with-attrs sym args attrs-merge)

Given a symbol and args, returns [<name-with-attrs-meta> <args> <attrs>] with support for defn style ?docstring and ?attrs-map.

Given a symbol and args, returns [<name-with-attrs-meta> <args> <attrs>]
with support for `defn` style `?docstring` and `?attrs-map`.
raw docstring

named?clj/s

(named? x)

nano-timeclj/s


nano-time*clj/smacro

(nano-time* & args)

nanoidclj/s

(nanoid)
(nanoid len)

Experimental. Optimized variant of secure-rand-id that returns Nano IDs as in https://github.com/ai/nanoid.

Experimental. Optimized variant of `secure-rand-id` that returns Nano IDs
as in https://github.com/ai/nanoid.
raw docstring

nanoid-alphabetclj/s


nat-float?clj/s

(nat-float? x)

nat-int?clj/s

(nat-int? x)

nat-num?clj/s

(nat-num? x)

nblank-str?clj/s

(nblank-str? x)

nblank?clj/s

(nblank? x)

neg-float?clj/s

(neg-float? x)

neg-int?clj/s

(neg-int? x)

neg-num?clj/s

(neg-num? x)

nempty-str?clj/s

(nempty-str? x)

nested-mergeclj/s

(nested-merge & maps)

Like merge but does nested merging.

Like `merge` but does nested merging.
raw docstring

nested-merge-withclj/s

(nested-merge-with f & maps)

Like merge-with but does nested merging.

Like `merge-with` but does nested merging.
raw docstring

new-objectclj/smacro

(new-object)

nil->sentinelclj/s

(nil->sentinel x)

nil->strclj/s

(nil->str x)

nil/undefined -> "nil"

nil/undefined -> "nil"
raw docstring

nneg-float?clj/s


nneg-int?clj/s


nneg-num?clj/s


nneg?clj/s

(nneg? x)

nnilclj/s

(nnil)
(nnil x)
(nnil x y)
(nnil x y z)
(nnil x y z & more)

Returns first non-nil arg, or nil.

Returns first non-nil arg, or nil.
raw docstring

nnil-setclj/s

(nnil-set x)

nnil=clj/s


nnil?clj/s


node-pathsclj/s

(node-paths m)
(node-paths node-pred m)
(node-paths node-pred m basis)

node-target?cljs


norm-strclj

(norm-str s)
(norm-str form s)

Given a Unicode string, returns the normalized de/composed form. It's often a good idea to normalize strings before exchange or storage, especially if you're going to be querying against those string.

form is ∈ #{:nfc :nfkc :nfd :nfkd <java.text.NormalizerForm>}. Defaults to :nfc as per W3C recommendation.

Given a Unicode string, returns the normalized de/composed form.
It's often a good idea to normalize strings before exchange or storage,
especially if you're going to be querying against those string.

`form` is ∈ #{:nfc :nfkc :nfd :nfkd <java.text.NormalizerForm>}.
Defaults to :nfc as per W3C recommendation.
raw docstring

norm-word-breaksclj/s

(norm-word-breaks s)

Converts all word breaks of any form and length (including line breaks of any form, tabs, spaces, etc.) to a single regular space.

Converts all word breaks of any form and length (including line breaks of any
form, tabs, spaces, etc.) to a single regular space.
raw docstring

normalize-headersclj

(normalize-headers rreq-or-rresp)

now-dtclj/s

(now-dt)

now-dt*clj/smacro

(now-dt*)

now-nanoclj/s≠

clj
(now-nano)
cljs

Uses window context as epoch, Ref. http://goo.gl/mWZWnR

Uses window context as epoch, Ref. http://goo.gl/mWZWnR
raw docstring

now-nano*clj/smacro

(now-nano*)

now-udtclj/s

(now-udt)

now-udt*clj/smacro

(now-udt*)

nvec?clj/s

(nvec? n x)

nzero-num?clj/s

(nzero-num? x)

ogetcljs

(oget k)
(oget o k)
(oget o k not-found)

Like get for JS objects.

Like `get` for JS objects.
raw docstring

oget-incljs

(oget-in ks)
(oget-in o ks)
(oget-in o ks not-found)

Like get-in for JS objects.

Like `get-in` for JS objects.
raw docstring

osetcljs

(oset o k v)

Like assoc for JS objects.

Like `assoc` for JS objects.
raw docstring

oset-incljs

(oset-in o ks v)

Experimental. Like assoc-in for JS objects.

Experimental. Like `assoc-in` for JS objects.
raw docstring

parse-boolclj/s


parse-floatclj/s


parse-intclj/s


parse-query-paramsclj/s

(parse-query-params s & [keywordize? encoding])

Based on ring-codec/form-decode.

Based on `ring-codec/form-decode`.
raw docstring

parse-versionclj/s

(parse-version x)

pathclj/s

(path & parts)

percclj/s

(perc n divisor)

pint?clj/s


pnum-complementclj/s

(pnum-complement pnum)

pnum?clj/s

(pnum? x)

Returns true iff given number in unsigned unit proportion interval ∈ℝ[0,1].

Returns true iff given number in unsigned unit proportion interval ∈ℝ[0,1].
raw docstring

pos-float?clj/s

(pos-float? x)

pos-int?clj/s

(pos-int? x)

pos-num?clj/s

(pos-num? x)

powclj/s

(pow n exp)

pr-ednclj/s

(pr-edn x)
(pr-edn _opts x)

Prints arg to an edn string readable with read-edn.

Prints arg to an edn string readable with `read-edn`.
raw docstring

pre-cacheclj

(pre-cache n-capacity f)
(pre-cache n-capacity fp-or-n-threads f)

Given a nullary fn f that is non-idempotent and free of side effects, returns a wrapped version of f that asynchronously maintains a cache of up to n-capacity pre-computed return values of (f).

Useful when f is expensive & may be called in a spikey fashion, e.g. ideal for cryptographic key generators.

Given a nullary fn `f` that is non-idempotent and free of side effects,
returns a wrapped version of `f` that asynchronously maintains a cache
of up to `n-capacity` pre-computed return values of (f).

Useful when `f` is expensive & may be called in a spikey fashion,
e.g. ideal for cryptographic key generators.
raw docstring

preserve-reducedclj/s

(preserve-reduced rf)

As core/preserving-reduced.

As `core/preserving-reduced`.
raw docstring

pull-val!clj/s

(pull-val! atom_ k)
(pull-val! atom_ k not-found)

Removes and returns value mapped to key.

Removes and returns value mapped to key.
raw docstring

pval?clj/s


qbclj/smacro

(qb spec form)
(qb spec form & more)

Simple util to benchmark/compare runtime of given form/s.

Runs sets of laps for each given form, recording the total runtime of each set. Returns the the total runtime in msecs of the fastest set of laps for each form.

(quick-bench [<num-sets> <num-laps>] <form1> <form2> <...>) => [<total runtime msecs of fastest set of laps for form1> <total runtime msecs of fastest set of laps for form2> <...>]

Total number of runs for each form is: num-sets * num-laps

If omitted, the default num-sets is 6 (to include warmup): (quick-bench <num-laps> <form1> <form2> <...>)

Example (comparing runtime of first and nth against vector): (let [v [:a]] (quick-bench 1e6 (first v) (nth v 0))) => [67.43 39.05]

Simple util to benchmark/compare runtime of given form/s.

Runs sets of laps for each given form, recording the total runtime of each set.
Returns the the total runtime in msecs of the fastest set of laps for each form.

  (quick-bench [<num-sets> <num-laps>] <form1> <form2> <...>) =>
    [<total runtime msecs of fastest set of laps for form1>
     <total runtime msecs of fastest set of laps for form2>
     <...>]

   Total number of runs for each form is: `num-sets` * `num-laps`

If omitted, the default `num-sets` is 6 (to include warmup):
  (quick-bench <num-laps> <form1> <form2> <...>)

Example (comparing runtime of `first` and `nth` against vector):
  (let [v [:a]] (quick-bench 1e6 (first v) (nth v 0))) => [67.43 39.05]
raw docstring

qbenchclj/smacro

(qbench & args)

qnameclj/s


qualified-ident?clj/s

(qualified-ident? x)

qualified-keyword?clj/s

(qualified-keyword? x)

qualified-symbol?clj/s

(qualified-symbol? x)

queueclj/s

(queue)
(queue coll)

Returns a PersistentQueue.

Returns a PersistentQueue.
raw docstring

queue*clj/s

(queue* & items)

queue?clj/s

(queue? x)

quick-benchclj/smacro

(quick-bench spec form)
(quick-bench spec form & more)

Simple util to benchmark/compare runtime of given form/s.

Runs sets of laps for each given form, recording the total runtime of each set. Returns the the total runtime in msecs of the fastest set of laps for each form.

(quick-bench [<num-sets> <num-laps>] <form1> <form2> <...>) => [<total runtime msecs of fastest set of laps for form1> <total runtime msecs of fastest set of laps for form2> <...>]

Total number of runs for each form is: num-sets * num-laps

If omitted, the default num-sets is 6 (to include warmup): (quick-bench <num-laps> <form1> <form2> <...>)

Example (comparing runtime of first and nth against vector): (let [v [:a]] (quick-bench 1e6 (first v) (nth v 0))) => [67.43 39.05]

Simple util to benchmark/compare runtime of given form/s.

Runs sets of laps for each given form, recording the total runtime of each set.
Returns the the total runtime in msecs of the fastest set of laps for each form.

  (quick-bench [<num-sets> <num-laps>] <form1> <form2> <...>) =>
    [<total runtime msecs of fastest set of laps for form1>
     <total runtime msecs of fastest set of laps for form2>
     <...>]

   Total number of runs for each form is: `num-sets` * `num-laps`

If omitted, the default `num-sets` is 6 (to include warmup):
  (quick-bench <num-laps> <form1> <form2> <...>)

Example (comparing runtime of `first` and `nth` against vector):
  (let [v [:a]] (quick-bench 1e6 (first v) (nth v 0))) => [67.43 39.05]
raw docstring

rate-limitclj/s

(rate-limit specs f)

rate-limitedclj/s

(rate-limited ncalls-limit window-ms f)

rate-limiterclj/s

(rate-limiter ncalls-limit window-ms)

rate-limiter*clj/s

(rate-limiter* specs)

Deprecated, prefer limiter

Deprecated, prefer `limiter`
raw docstring

rcompareclj/s

(rcompare x y)

Reverse comparator.

Reverse comparator.
raw docstring

re-pattern?clj/s

(re-pattern? x)

read-ednclj/s

(read-edn s)
(read-edn opts s)

Attempts to pave over differences in: clojure.edn/read-string, clojure.tools.edn/read-string, cljs.reader/read-string, cljs.tools.reader/read-string. cljs.reader in particular can be a pain.

Attempts to pave over differences in:
 `clojure.edn/read-string`, `clojure.tools.edn/read-string`,
 `cljs.reader/read-string`, `cljs.tools.reader/read-string`.
`cljs.reader` in particular can be a pain.
raw docstring

read-sys-valclj

(read-sys-val id)
(read-sys-val prop-id env-id)

redirect-respclj


reduce-indexedclj/s

(reduce-indexed rf init coll)

Like reduce but takes (rf [acc idx in]) with idx as in map-indexed. As reduce-kv against vector coll, but works on any seqable coll type.

Like `reduce` but takes (rf [acc idx in]) with idx as in `map-indexed`.
As `reduce-kv` against vector coll, but works on any seqable coll type.
raw docstring

reduce-kvsclj/s

(reduce-kvs rf init kvs)

Like reduce-kv but takes a flat sequence of kv pairs.

Like `reduce-kv` but takes a flat sequence of kv pairs.
raw docstring

reduce-nclj/s

(reduce-n rf init end)
(reduce-n rf init start end)
(reduce-n rf init start end step)

reduce-objcljs

(reduce-obj f init o)

Like reduce-kv but for JavaScript objects.

Like `reduce-kv` but for JavaScript objects.
raw docstring

reduce-topclj/s

(reduce-top n rf init coll)
(reduce-top n keyfn rf init coll)
(reduce-top n keyfn cmp rf init coll)

Reduces the top n items from coll of N items. Clj impln is O(N.logn) vs O(N.logN) for (take n (sort-by ...)).

Reduces the top `n` items from `coll` of N items.
Clj impln is O(N.logn) vs O(N.logN) for (take n (sort-by ...)).
raw docstring

reduce-zipclj/s

(reduce-zip rf init xs ys)

Reduces given sequential xs and ys as pairs (e.g. key-val pairs). Calls (rf acc x y) for each sequential pair.

Useful, among other things, as a more flexible version of zipmap.

Reduces given sequential xs and ys as pairs (e.g. key-val pairs).
Calls (rf acc x y) for each sequential pair.

Useful, among other things, as a more flexible version of `zipmap`.
raw docstring

regular-num?cljs


remove-keysclj/s

(remove-keys pred m)

remove-kvsclj/s

(remove-kvs pred m)

remove-valsclj/s

(remove-vals pred m)

removevclj/s

(removev pred coll)

rename-keysclj/s

(rename-keys replacements m)

Returns a map like the one given, replacing keys using the given {<old-new> <new-key>} replacements. O(min(n_replacements, n_m)).

Returns a map like the one given, replacing keys using
the given {<old-new> <new-key>} replacements.
O(min(n_replacements, n_m)).
raw docstring

repeatedly*clj/smacro

(repeatedly* n & body)

repeatedly-intoclj/s

(repeatedly-into coll n f)

Like repeatedly but faster and conjs items into given collection.

Like `repeatedly` but faster and `conj`s items into given collection.
raw docstring

repeatedly-into*clj/smacro

(repeatedly-into* coll n & body)

Deprecated

Deprecated
raw docstring

replace-inclj/s

(replace-in m & ops)

reportfcljs

(reportf fmt & xs)

reset!?clj/s

(reset!? atom_ val)

Atomically swaps value of atom_ to val and returns true iff the atom's value changed. See also reset-in!?.

Atomically swaps value of `atom_` to `val` and returns
true iff the atom's value changed. See also `reset-in!?`.
raw docstring

reset-in!clj/s

(reset-in! atom_ val)
(reset-in! atom_ ks val)
(reset-in! atom_ ks not-found val)

Like reset! but supports update-in semantics, returns <old-key-val>.

Like `reset!` but supports `update-in` semantics, returns <old-key-val>.
raw docstring

reset-in!?clj/s

(reset-in!? atom_ val)
(reset-in!? atom_ ks val)
(reset-in!? atom_ ks not-found val)

Like reset-in! but returns true iff the atom's value changed.

Like `reset-in!` but returns true iff the atom's value changed.
raw docstring

reset-val!clj/s

(reset-val! atom_ k val)
(reset-val! atom_ k not-found val)

Like reset-in! but optimized for single-key case.

Like `reset-in!` but optimized for single-key case.
raw docstring

reset-val!?clj/s

(reset-val!? atom_ k new-val)

Like reset-in!? but optimized for single-key case.

Like `reset-in!?` but optimized for single-key case.
raw docstring

resolve-symclj

(resolve-sym sym)
(resolve-sym env sym)

Resolves given symbol to qualified clj/s symbol, or nil.

Resolves given symbol to qualified clj/s symbol, or nil.
raw docstring

resolve-varclj

(resolve-var sym)
(resolve-var env sym)

Resolves given symbol to clj/s var, or nil.

Resolves given symbol to clj/s var, or nil.
raw docstring

reveryclj/s

(revery pred coll)

revery-kvclj/s

(revery-kv pred coll)

revery-kv?clj/s

(revery-kv? pred coll)

revery?clj/s

(revery? pred coll)
(revery? xform pred coll)

rfirstclj/s

(rfirst pred coll)
(rfirst xform pred coll)

rfirst-kvclj/s

(rfirst-kv pred coll)

ring-default-headersclj

(ring-default-headers headers rresp)

ring-merge-headersclj

(ring-merge-headers headers rresp)

ring-redirect-respclj

(ring-redirect-resp url)
(ring-redirect-resp kind url)
(ring-redirect-resp kind url flash)

ring-resp-mapclj

(ring-resp-map x)

ring-set-bodyclj

(ring-set-body body rresp)

ring-set-headersclj

(ring-set-headers headers rresp)

ring-set-statusclj

(ring-set-status code rresp)

rnum?clj/s

(rnum? x)

Returns true iff given number in signed unit proportion interval ∈ℝ[-1,1].

Returns true iff given number in signed unit proportion interval ∈ℝ[-1,1].
raw docstring

rolling-counterclj/s

(rolling-counter msecs)

Experimental. Returns a RollingCounter that you can:

  • Invoke to increment count in last msecs window and return RollingCounter.
  • Deref to return count in last msecs window.
Experimental. Returns a RollingCounter that you can:
- Invoke to increment count in last `msecs` window and return RollingCounter.
- Deref  to return    count in last `msecs` window.
raw docstring

rolling-listclj

(rolling-list nmax)
(rolling-list nmax {:keys [init-val]})

Returns a stateful fn of 2 arities: (fn [ ]) => Returns current array in O(n). (fn [x]) => Adds x to right of list, maintaining length <~ nmax. Returns nil. Very fast (faster than rolling-vector).

Useful for maintaining limited-length histories, etc. See also rolling-vector.

Returns a stateful fn of 2 arities:
  (fn [ ]) => Returns current array in O(n).
  (fn [x]) => Adds `x` to right of list, maintaining length <~ `nmax`.
              Returns nil. Very fast (faster than `rolling-vector`).

Useful for maintaining limited-length histories, etc.
See also `rolling-vector`.
raw docstring

rolling-vectorclj/s

(rolling-vector nmax)
(rolling-vector nmax {:keys [gc-every init-val] :or {gc-every 16000.0}})

Returns a stateful fn of 2 arities: (fn [ ]) => Returns current sub/vector in O(1). (fn [x]) => Adds x to right of sub/vector, maintaining length <= nmax. Returns current sub/vector.

Useful for maintaining limited-length histories, etc. See also rolling-list (Clj only).

Returns a stateful fn of 2 arities:
  (fn [ ]) => Returns current sub/vector in O(1).
  (fn [x]) => Adds `x` to right of sub/vector, maintaining length <= `nmax`.
              Returns current sub/vector.

Useful for maintaining limited-length histories, etc.
See also `rolling-list` (Clj only).
raw docstring

roundclj/s

(round n & [type nplaces])

round*clj/s

(round* n)
(round* kind n)
(round* kind precision n)

round0clj/s

(round0 n)

round1clj/s

(round1 n)

round2clj/s

(round2 n)

roundnclj/s

(roundn precision n)

rsomeclj/s

(rsome pred coll)
(rsome xform pred coll)

rsome-kvclj/s

(rsome-kv pred coll)

run!clj/s

(run! proc coll)

run!*clj/s


run-kv!clj/s

(run-kv! proc m)

run-kvs!clj/s

(run-kvs! proc kvs)

run-obj!cljs

(run-obj! proc obj)

satisfies!clj/s

(satisfies! protocol arg & {:as details})

If (satisfies? protocol arg) is true, returns arg. Otherwise throws runtime ExceptionInfo with unexpected-arg!. See unexpected-arg! for more info.

If (satisfies? protocol arg) is true, returns arg.
Otherwise throws runtime `ExceptionInfo` with `unexpected-arg!`.
See `unexpected-arg!` for more info.
raw docstring

sayfcljs

(sayf fmt & xs)

saypcljs

(sayp & xs)

sb-appendclj/s

(sb-append str-builder s)
(sb-append str-builder s & more)

For cross-platform string building

For cross-platform string building
raw docstring

secsclj/s


secs->msclj/s

(secs->ms secs)

secure-rand-bytesclj/s

(secure-rand-bytes size)

Returns size random bytes using secure-rng or js/window.crypto.

Returns `size` random bytes using `secure-rng` or `js/window.crypto`.
raw docstring

secure-rand-idclj/s

(secure-rand-id alphabet len)

Experimental. Given alphabet (a string of possible characters), returns a securely random string of length len.

Trying to do this the obvious/naive way (by repeatedly generating a secure random number and mapping it to an alphabet character with modulo) actually introduces bias into ids that can be exploited by an attacker.

The method used here is designed to eliminate that bias. Based on https://bit.ly/3dtYv73.

Experimental.
Given `alphabet` (a string of possible characters), returns a securely
random string of length `len`.

Trying to do this the obvious/naive way (by repeatedly generating a secure
random number and mapping it to an alphabet character with modulo) actually
introduces bias into ids that can be exploited by an attacker.

The method used here is designed to eliminate that bias.
Based on https://bit.ly/3dtYv73.
raw docstring

secure-rngclj

(secure-rng)

Returns a thread-local java.security.SecureRandom. Favours security over performance. Automatically re-seeds occasionally. May block while waiting on system entropy!

Returns a thread-local `java.security.SecureRandom`.
Favours security over performance. Automatically re-seeds occasionally.
May block while waiting on system entropy!
raw docstring

secure-rng-mock!!!clj

(secure-rng-mock!!! long-seed)

Returns INSECURE java.security.SecureRandom mock instance backed by a seeded deterministic java.util.Random. Useful for testing, etc.

Returns **INSECURE** `java.security.SecureRandom` mock instance backed by
a seeded deterministic `java.util.Random`. Useful for testing, etc.
raw docstring

select-nested-keysclj/s

(select-nested-keys src-map key-spec)

Like select-keys but supports nested key spec:

(select-nested-keys {:a :A :b :B :c {:c1 :C1 :c2 :C2} :d :D} ; src-map [:a {:c [:c1], :d [:d1 :d2]}]) ; key-spec

=> {:a :A, :c {:c1 :C1}, :d :D}

Note that as with the {:d [:d1 :d2]} spec in the example above, if spec expects a nested map but the actual value is not a map, the actual value will be included in output as-is.

Has the same behaviour as select-keys when key-spec is a simple vector of keys.

Like `select-keys` but supports nested key spec:

  (select-nested-keys
    {:a :A :b :B :c {:c1 :C1 :c2 :C2} :d :D} ; `src-map`
    [:a {:c [:c1], :d [:d1 :d2]}]) ; `key-spec`

    => {:a :A, :c {:c1 :C1}, :d :D}

Note that as with the `{:d [:d1 :d2]}` spec in the example above,
if spec expects a nested map but the actual value is not a map,
the actual value will be included in output as-is.

Has the same behaviour as `select-keys` when `key-spec` is a
simple vector of keys.
raw docstring

sentinelclj/s


sentinel->nilclj/s

(sentinel->nil x)

sentinel?clj/s

(sentinel? x)

seq-kvsclj/s

(seq-kvs {:a :A}) => (:a :A).

(seq-kvs {:a :A}) => (:a :A).
raw docstring

session-swapclj

(session-swap rreq rresp f & args)

Small util to help correctly manage (modify) funtional sessions. Please use this when writing Ring middleware! It's so easy to get this wrong and end up with subtle, tough-to-diagnose issues.

Small util to help correctly manage (modify) funtional sessions. Please use
this when writing Ring middleware! It's *so* easy to get this wrong and end up
with subtle, tough-to-diagnose issues.
raw docstring

set*clj/s


set-bodyclj

(set-body rresp body)

set-exp-backoff-timeout!cljs

(set-exp-backoff-timeout! nullary-f & [nattempt])

set-statusclj

(set-status rresp code)

simple-date-formatclj

(simple-date-format pattern & [{:keys [locale timezone] :as opts}])

Returns a thread-local java.text.SimpleDateFormat.

Returns a thread-local `java.text.SimpleDateFormat`.
raw docstring

simple-date-format*clj

(simple-date-format* pattern locale timezone)

simple-ident?clj/s

(simple-ident? x)

simple-keyword?clj/s

(simple-keyword? x)

simple-symbol?clj/s

(simple-symbol? x)

singleton?clj/s

(singleton? coll)

slurp-file-resourceclj

Like slurp-resource but caches slurps against file's last-modified udt.

Like `slurp-resource` but caches slurps against file's last-modified udt.
raw docstring

slurp-resourceclj

(slurp-resource rname)

Returns slurped named resource on classpath, or nil when resource not found.

Returns slurped named resource on classpath, or nil when resource not found.
raw docstring

some=clj/s

(some= x y)
(some= x y & more)

some?clj/s

(some? x)

sortvclj/s

(sortv coll)
(sortv comparator coll)
(sortv ?keyfn comparator coll)

Like core/sort but:

  • Returns a vector.
  • comparator can be :asc, :desc, or an arbitrary comparator.
  • An optional keyfn may be provided, as in core/sort-by.
Like `core/sort` but:
- Returns a vector.
- `comparator` can be `:asc`, `:desc`, or an arbitrary comparator.
- An optional `keyfn` may be provided, as in `core/sort-by`.
raw docstring

spaced-strclj/s

(spaced-str xs)

spaced-str-with-nilsclj/s

(spaced-str-with-nils xs)

srngclj


str->utf8-baclj

(str->utf8-ba s)

str-?indexclj/s

(str-?index s substr)
(str-?index s substr start-idx)
(str-?index s substr start-idx last?)

str-builderclj/s

For cross-platform string building

For cross-platform string building
raw docstring

str-builder?clj/s

(str-builder? x)

str-contains?clj/s

(str-contains? s substr)

str-ends-with?clj/s

(str-ends-with? s substr)

str-joinclj/s

(str-join coll)
(str-join separator coll)
(str-join separator xform coll)

Faster, transducer-based generalization of clojure.string/join with xform support.

Faster, transducer-based generalization of `clojure.string/join` with `xform`
support.
raw docstring

str-join-onceclj/s

(str-join-once separator coll)

Like string/join but skips duplicate separators.

Like `string/join` but skips duplicate separators.
raw docstring

str-replaceclj/s

(str-replace s match replacement)

Like str/replace but provides consistent clj/s behaviour.

Workaround for http://dev.clojure.org/jira/browse/CLJS-794, http://dev.clojure.org/jira/browse/CLJS-911.

Note that ClojureScript 1.7.145 introduced a partial fix for CLJS-911. A full fix could unfortunately not be introduced w/o breaking compatibility with the previously incorrect behaviour. CLJS-794 also remains unresolved.

Like `str/replace` but provides consistent clj/s behaviour.

Workaround for http://dev.clojure.org/jira/browse/CLJS-794,
               http://dev.clojure.org/jira/browse/CLJS-911.

Note that ClojureScript 1.7.145 introduced a partial fix for CLJS-911.
A full fix could unfortunately not be introduced w/o breaking compatibility
with the previously incorrect behaviour. CLJS-794 also remains unresolved.
raw docstring

str-rfclj/s

String builder reducing fn

String builder reducing fn
raw docstring

str-starts-with?clj/s

(str-starts-with? s substr)

stringy?clj/s

(stringy? x)

sub-indexesclj/s

(sub-indexes x start-idx & {:keys [max-len end-idx]})

submap?clj/s

(submap? m sub)

Returns true iff sub is a (possibly nested) submap of m, i.e. iff every (nested) value in sub has the same (nested) value in m.

Warning: uses stack recursion, so supports only limited nesting.

Returns true iff `sub` is a (possibly nested) submap of `m`,
i.e. iff every (nested) value in `sub` has the same (nested) value in `m`.

Warning: uses stack recursion, so supports only limited nesting.
raw docstring

substrclj/s

(substr s start-idx & [?max-len])

Deprecated, prefer get-substr-by-idx or get-substr-by-len

Deprecated, prefer `get-substr-by-idx` or `get-substr-by-len`
raw docstring

subvec*clj/s

(subvec* v start-idx & [?max-len])

Deprecated, prefer get-subvec or get-subvector

Deprecated, prefer `get-subvec` or `get-subvector`
raw docstring

swap!*clj/s


swap-in!clj/s

(swap-in! atom_ f)
(swap-in! atom_ ks f)
(swap-in! atom_ ks not-found f)

Like swap! but supports update-in semantics, returns <new-key-val> or <swapped-return-val>.

Like `swap!` but supports `update-in` semantics,
returns <new-key-val> or <swapped-return-val>.
raw docstring

swap-in!*clj/s

(swap-in!* atom_ f)
(swap-in!* atom_ ks f)
(swap-in!* atom_ ks not-found f)

Deprecated, prefer swap-in! with swapped return value.

Deprecated, prefer `swap-in!` with `swapped` return value.
raw docstring

swap-val!clj/s

(swap-val! atom_ k f)
(swap-val! atom_ k not-found f)

Like swap-in! but optimized for single-key case.

Like `swap-in!` but optimized for single-key case.
raw docstring

swap-val!*clj/s

(swap-val!* atom_ k f)
(swap-val!* atom_ k not-found f)

Deprecated, prefer swap-val! with swapped return value.

Deprecated, prefer `swap-val!` with `swapped` return value.
raw docstring

swappedclj/s

(swapped new-val return-val)

swapped*clj/s


swapped-vecclj/s

(swapped-vec x)

swapped?clj/s

(swapped? x)

system-newlineclj/s


takevclj/s

(takev n coll)

test-fixturesclj/s

(test-fixtures fixtures-map)

Given a {:before ?(fn []) :after ?(fn [])} map, returns cross-platform test fixtures for use by both clojure.test and cljs.test:

(let [f (test-fixtures {:before (fn [] (test-setup))})] (clojure.test/use-fixtures :once f) (cljs.test/use-fixtures :once f))

Given a {:before ?(fn []) :after ?(fn [])} map, returns cross-platform
test fixtures for use by both `clojure.test` and `cljs.test`:

  (let [f (test-fixtures {:before (fn [] (test-setup))})]
    (clojure.test/use-fixtures :once f)
       (cljs.test/use-fixtures :once f))
raw docstring

thread-localclj/smacro

(thread-local & body)

Given a body that returns an initial value for the current thread, returns a ThreadLocal proxy that can be derefed to get the current thread's current value.

Commonly used to achieve thread safety during Java interop. In the common case, body will be a call to some Java constructor that returns a non-thread-safe instance.

Example: (def thread-local-simple-date-format_ "Deref to return a thread-local SimpleDateFormat" (thread-local (SimpleDateFormat. "yyyy-MM-dd")))

(.format @thread-local-simple-date-format_ (Date.)) => "2023-01-24"

NB: don't pass the derefed value to other threads!

Given a body that returns an initial value for the current thread,
returns a `ThreadLocal` proxy that can be derefed to get the current
thread's current value.

Commonly used to achieve thread safety during Java interop.
In the common case, `body` will be a call to some Java constructor
that returns a non-thread-safe instance.

Example:
  (def thread-local-simple-date-format_
    "Deref to return a thread-local `SimpleDateFormat`"
    (thread-local (SimpleDateFormat. "yyyy-MM-dd")))

  (.format @thread-local-simple-date-format_ (Date.)) => "2023-01-24"

NB: don't pass the derefed value to other threads!
raw docstring

thread-local*clj

(thread-local* init-val-fn)

Low-level, see thread-local instead.

Low-level, see `thread-local` instead.
raw docstring

thread-local-proxyclj/smacro

(thread-local-proxy & body)

Low-level, see thread-local instead.

Low-level, see `thread-local` instead.
raw docstring

throwable?clj

(throwable? x)

thrownclj/smacrodeprecated

(thrown & args)

Prefer throws

Prefer `throws`
raw docstring

throwsclj/smacro

(throws form)
(throws c form)
(throws c pattern form)

Like throws?, but returns ?matching-error instead of true/false.

Like `throws?`, but returns ?matching-error instead of true/false.
raw docstring

throws?clj/smacro

(throws? form)
(throws? c form)
(throws? c pattern form)

Evals form and returns true iff it throws an error that matches given criteria:

  • c may be:

    • A predicate function, (fn match? [x]) -> bool
    • A class (e.g. ArithmeticException, AssertionError, etc.)
    • :all => any platform error (Throwable or js/Error, etc.)
    • :common => common platform error (Exception or js/Error)
  • pattern may be:

    • A string or Regex against which ex-message will be matched.
    • A map against which ex-data will be matched.

When an error with (nested) causes doesn't match, a match will be attempted against its (nested) causes.

Useful for unit tests, e.g.: (is (throws? {:a :b} (throw (ex-info "Test" {:a :b :c :d}))))

See also throws.

Evals `form` and returns true iff it throws an error that matches given
criteria:

  - `c` may be:
    - A predicate function, (fn match? [x]) -> bool
    - A class (e.g. ArithmeticException, AssertionError, etc.)
    - `:all`    => any    platform error (Throwable or js/Error, etc.)
    - `:common` => common platform error (Exception or js/Error)

  - `pattern` may be:
    - A string or Regex against which `ex-message` will be matched.
    - A map             against which `ex-data`    will be matched.

When an error with (nested) causes doesn't match, a match will be attempted
against its (nested) causes.

Useful for unit tests, e.g.:
  (is (throws? {:a :b} (throw (ex-info "Test" {:a :b :c :d}))))

See also `throws`.
raw docstring

time-msclj/smacro

(time-ms & body)

Returns number of milliseconds it took to execute body.

Returns number of milliseconds it took to execute body.
raw docstring

time-nsclj/smacro

(time-ns & body)

Returns number of nanoseconds it took to execute body.

Returns number of nanoseconds it took to execute body.
raw docstring

timeout-future?clj/s

(timeout-future? x)

topclj/s

(top n coll)
(top n keyfn coll)
(top n keyfn cmp coll)

Returns a sorted vector of the top n items from coll using reduce-top.

Returns a sorted vector of the top `n` items from `coll` using `reduce-top`.
raw docstring

top-intoclj/s

(top-into to n coll)
(top-into to n keyfn coll)
(top-into to n keyfn cmp coll)

Conjoins the top n items from coll into to using reduce-top.

Conjoins the top `n` items from `coll` into `to` using `reduce-top`.
raw docstring

tracefcljs

(tracef fmt & xs)

transient?clj/s

(transient? x)

try-evalclj/smacro

(try-eval form)

Evaluates form. If eval doesn't throw, expands to form, otherwise to nil.

Evaluates `form`. If eval doesn't throw, expands to `form`, otherwise to nil.
raw docstring

udt?clj/s

(udt? x)

uint?clj/s


undefined->nilcljs

(undefined->nil x)

unexpected-arg!clj/s

(unexpected-arg! arg & {:keys [msg] :as details})

Throws runtime ExceptionInfo to indicate an unexpected argument. Takes optional kvs for merging into exception's data map.

(let [mode :unexpected] (case mode :read (do <...>) :write (do <...>) (unexpected-arg! mode :expected #{:read :write}))) =>

Unexpected argument: :unexpected {:arg {:value :unexpected, :type clojure.lang.Keyword}, :expected #{:read :write}}

Throws runtime `ExceptionInfo` to indicate an unexpected argument.
Takes optional kvs for merging into exception's data map.

  (let [mode :unexpected]
    (case mode
      :read  (do <...>)
      :write (do <...>)
      (unexpected-arg! mode
        :expected #{:read :write}))) =>

  Unexpected argument: :unexpected
  {:arg {:value :unexpected, :type clojure.lang.Keyword},
   :expected #{:read :write}}
raw docstring

update-inclj/s

(update-in m ks f)
(update-in m ks not-found f)

Like core/update-in but:.

  • Empty ks will return (f m), not act like [nil] ks.
  • Adds support for not-found.
  • Adds support for special return vals: :swap/dissoc, :swap/abort.
Like `core/update-in` but:.
- Empty ks will return (f m), not act like [nil] ks.
- Adds support for `not-found`.
- Adds support for special return vals: `:swap/dissoc`, `:swap/abort`.
raw docstring

update-in*clj/s


uri?clj

(uri? x)

url-decodeclj/s

(url-decode s & [encoding])
Stolen from http://goo.gl/99NSR1
raw docstring

url-encodeclj/s≠

clj
(url-encode s & [encoding])
cljs
(url-encode s)
Based on https://goo.gl/fBqy6e
raw docstring

use-fixtures*clj/smacro

(use-fixtures* & args)

utf8-ba->strclj

(utf8-ba->str ba)

uuid-strclj/s

(uuid-str)
(uuid-str max-length)
Returns a UUIDv4 string of form "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".
Ref. http://www.ietf.org/rfc/rfc4122.txt,
     https://gist.github.com/franks42/4159427,
     https://github.com/clojure/clojurescript/pull/194
raw docstring

vec*clj/s


vec2?clj/s

(vec2? x)

vec3?clj/s

(vec3? x)

vinterleave-allclj/s

(vinterleave-all c1 c2)

vnextclj/s

(vnext v)

vrestclj/s

(vrest v)

vsplit-firstclj/s

(vsplit-first v)

vsplit-lastclj/s

(vsplit-last v)

warnfcljs

(warnf fmt & xs)

whenclj/smacro

(when test-or-bindings & body)

Like core/when but acts like when-let when given a binding vector as test expr.

Like `core/when` but acts like `when-let` when given a binding vector
as test expr.
raw docstring

when-letclj/smacro

(when-let bindings & body)

Like core/when-let but can bind multiple values for body iff all tests are truthy, supports internal unconditional :lets.

Like `core/when-let` but can bind multiple values for `body` iff all tests
are truthy, supports internal unconditional `:let`s.
raw docstring

when-letsclj/smacro

(when-lets & args)

when-notclj/smacro

(when-not test-or-bindings & body)

Like core/when-not but acts like when-let when given a binding vector as test expr.

Like `core/when-not` but acts like `when-let` when given a binding vector
as test expr.
raw docstring

when-someclj/smacro

(when-some test-or-bindings & body)

when?clj/s

(when? pred x)

with-dynamic-assertion-dataclj/smacrodeprecated

(with-dynamic-assertion-data data & body)

Prefer with-data

Prefer `with-data`
raw docstring

with-truss-dataclj/smacro

(with-truss-data data & body)

Executes body with dynamic assertion data bound to given value. This data will be included in any violation errors thrown by body.

Executes body with dynamic assertion data bound to given value.
This data will be included in any violation errors thrown by body.
raw docstring

without-metaclj/s

(without-meta x)

xdistinctclj/s

(xdistinct)
(xdistinct keyfn)

zero-num?clj/s

(zero-num? x)

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

× close