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

taoensso.encore

Extended core library for Clojure/Script that emphasizes:

  • Cross-platform API
  • 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.

Common naming conventions used across my libs: 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): [wip] - 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)

[doc] - Documentation changes besides those better labelled as [mod], [fix], or [new] [nop] - Other non-breaking changes (to implementation details, 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
  * 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.

Common naming conventions used across my libs:
  **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):
  [wip]   - 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)

  [doc]   - Documentation changes besides those better labelled as [mod], [fix], or [new]
  [nop]   - Other non-breaking changes (to implementation details, 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

<*clj/smacro

(<* x y z)

<=*clj/smacro

(<=* x y z)

>*clj/smacro

(>* x y z)

>=*clj/smacro

(>=* x y z)

a-utf8-strclj/s

Example UTF-8 string for tests, etc.

Example UTF-8 string for tests, etc.
raw docstring

abbreviate-nsclj/s

(abbreviate-ns x)
(abbreviate-ns n-full x)

Give any nameable type (string, keyword, symbol), returns the same type with at most n-full (default 1) unabbreviated namespace parts.

Example: (abbreviate-ns 2 :foo.bar/baz) => :foo.bar/baz (abbreviate-ns 1 :foo.bar/baz) => :f.bar/baz (abbreviate-ns 0 :foo.bar/baz) => :f.b/baz

Give any nameable type (string, keyword, symbol), returns the same
type with at most `n-full` (default 1) unabbreviated namespace parts.

Example:
  (abbreviate-ns 2 :foo.bar/baz) => :foo.bar/baz
  (abbreviate-ns 1 :foo.bar/baz) =>   :f.bar/baz
  (abbreviate-ns 0 :foo.bar/baz) =>     :f.b/baz
raw docstring

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-callcljs

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

Queues a lightweight Ajax call with Google Closure's goog.net.XhrIo and returns nil, or the resulting goog.net.XhrIo instance if one was immediately available from the XHR pool:

(ajax-call "http://localhost:8080/my-post-route" ; Endpoint URL

{:method     :post ; ∈ #{:get :post :put}
 :resp-type  :text ; ∈ #{:auto :edn :json :xml :text
                   ;     :bin/array-buffer :bin/blob}   ; Expected response type

 :headers {"Content-Type" "text/plain"}             ; Request headers
 :params  {:username "Rich Hickey" :type "Awesome"} ; Request params

 :timeout-ms        10000       ; Request timeout in msecs
 :with-credentials? false       ; Enable if using CORS
 :xhr-pool          my-xhr-pool ; Optional `goog.net.XhrIoPool` instance or delay
 :xhr-cb-fn         (fn [xhr])  ; Optional fn to call with `XhrIo` from pool when available
 :xhr-timeout-ms    2500        ; Optional max msecs to wait on pool for `XhrIo`
}

(fn callback [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 :bad-edn}
    (js/alert (str "Ajax response: " resp-map)))))
Queues a lightweight Ajax call with Google Closure's `goog.net.XhrIo`
and returns nil, or the resulting `goog.net.XhrIo` instance if one was
immediately available from the XHR pool:

  (ajax-call
    "http://localhost:8080/my-post-route" ; Endpoint URL

    {:method     :post ; ∈ #{:get :post :put}
     :resp-type  :text ; ∈ #{:auto :edn :json :xml :text
                       ;     :bin/array-buffer :bin/blob}   ; Expected response type

     :headers {"Content-Type" "text/plain"}             ; Request headers
     :params  {:username "Rich Hickey" :type "Awesome"} ; Request params

     :timeout-ms        10000       ; Request timeout in msecs
     :with-credentials? false       ; Enable if using CORS
     :xhr-pool          my-xhr-pool ; Optional `goog.net.XhrIoPool` instance or delay
     :xhr-cb-fn         (fn [xhr])  ; Optional fn to call with `XhrIo` from pool when available
     :xhr-timeout-ms    2500        ; Optional max msecs to wait on pool for `XhrIo`
    }

    (fn callback [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 :bad-edn}
        (js/alert (str "Ajax response: " resp-map)))))
raw docstring

approx==clj/s

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

as-?boolclj/s

(as-?bool x)

as-?dtclj

(as-?dt x)

Returns given ?arg as java.util.Date, or nil.

Returns given ?arg as `java.util.Date`, or nil.
raw docstring

as-?emailclj/s

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

as-?floatclj/s

(as-?float x)

as-?instclj/s

(as-?inst x)

Returns given ?arg as platform instant (java.time.Instant or js/Date), or nil.

Returns given ?arg as platform instant (`java.time.Instant` or `js/Date`), or nil.
raw docstring

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-?pnumclj/s

(as-?pnum x)

as-?pos-floatclj/s

(as-?pos-float x)

as-?pos-intclj/s

(as-?pos-int x)

as-?qnameclj/s

(as-?qname x)

as-?rnumclj/s

(as-?rnum x)

as-?udtclj/s

(as-?udt x)

Returns given ?arg as (pos/neg) milliseconds since Unix epoch, or nil.

Returns given ?arg as (pos/neg) milliseconds since Unix epoch, or nil.
raw docstring

as-boolclj/s

(as-bool x)

as-dtclj

(as-dt x)

as-emailclj/s

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

as-floatclj/s

(as-float x)

as-instclj/s

(as-inst 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 x)
(as-nemail n x)

as-nempty-strclj/s

(as-nempty-str x)

as-nzeroclj/s

(as-nzero x)

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-qnameclj/s

(as-qname x)

as-rnumclj/s

(as-rnum x)

as-rnum!clj/s

(as-rnum! x)

as-udtclj/s

(as-udt x)

assert-min-encore-versionclj/smacro

(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 m-kvs)
(assoc-nx m k v)
(assoc-nx m k v & kvs)

Assocs each kv to given ?map iff its key doesn't already exist.

Assocs each kv to given ?map iff its key doesn't already exist.
raw docstring

assoc-someclj/s

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

Assocs each kv to given ?map iff its value is not nil.

Assocs each kv to given ?map iff its value is not nil.
raw docstring

assoc-whenclj/s

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

Assocs each kv to given ?map iff its val is truthy.

Assocs each kv to given ?map 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)

Returns hash int of given byte[].

Returns hash int of given byte[].
raw docstring

ba-splitclj

(ba-split ba idx)

ba=clj

(ba= x y)

Returns true iff given two byte[]s with the same content.

Returns true iff given two byte[]s with the same content.
raw docstring

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

bindingclj/smacrodeprecated

(binding bindings & body)

binding*clj/smacro

(binding* bindings & body)

For Clj: faster version of core/binding. For Cljs: identical to core/binding. Can interfere with some deep-walking macros.

For Clj: faster version of `core/binding`.
For Cljs: identical to `core/binding`.
Can interfere with some deep-walking macros.
raw docstring

boolean?clj/s

(boolean? x)

bytes-classclj


bytes?clj

(bytes? x)

Returns true iff given byte[] argument.

Returns true iff given byte[] argument.
raw docstring

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:

    • :cache/del ; Delete cached item for subsequent args, returns nil.
    • :cache/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:
    - `:cache/del`   ; Delete cached item for subsequent args, returns nil.
    - `:cache/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

call-on-shutdown!clj

(call-on-shutdown! f)

Registers given nullary fn as a JVM shutdown hook. (f) will be called sometime during shutdown. While running, it will attempt to block shutdown.

Registers given nullary fn as a JVM shutdown hook.
(f) will be called sometime during shutdown. While running, it will
attempt to block shutdown.
raw docstring

can-meta?clj/s

(can-meta? x)

case-evalclj/smacro

(case-eval expr & clauses)

Like case but test expressions are evaluated for their compile-time value.

Like `case` but test expressions are evaluated 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

catchingclj/smacro

(catching expr)
(catching error-type 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)

Terse, cross-platform (try* expr (catch :all _)). Arities besides #{1 2} are deprecated, prefer try* in these cases.

Terse, cross-platform (try* expr (catch :all _)).
Arities besides #{1 2} are deprecated, prefer `try*` in these cases.
raw docstring

chan?clj/s

(chan? x)

Returns true iff given a clojure.core.async channel.

Returns true iff given a `clojure.core.async` channel.
raw docstring

chanceclj/s

(chance prob)

Returns true with given probability ∈ ℝ[0,1].

Returns true with given probability ∈ ℝ[0,1].
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)

class-symclj

(class-sym x)

Returns class name symbol of given argument.

Returns class name symbol of given argument.
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-whenclj/smacro

(compile-when test & body)

condclj/smacro

(cond & clauses)

Supersets core/cond functionality. 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" :else "fallback value")

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

Supersets `core/cond` functionality. 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"
  :else    "fallback value")

Simple, flexible way to eliminate deeply-nested control flow code.
`:let` support inspired by <https://github.com/Engelberg/better-cond>.
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

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 integer value with:

  • @counter => Return current val
  • (counter) => Add 1 and return old val
  • (counter n) => Add n and return old val
  • (counter action n) => Experimental, action ∈ {:add :set :set-get :get-set :get-add :add-get}.
Returns a fast atomic `Counter` with `init` initial integer value with:
- @counter           => Return current val
- (counter)          => Add 1 and return old val
- (counter n)        => Add n and return old val
- (counter action n) => Experimental, action ∈
    {:add :set :set-get :get-set :get-add :add-get}.
raw docstring

declare-remoteclj/smacro

(declare-remote & syms)

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

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

def*clj/smacro

(def* sym ?docstring ?attrs-map init-expr)

Like core/def but supports attrs map.

Like `core/def` but supports attrs map.
raw docstring

defaliasclj/smacro

(defalias src)
(defalias alias src)
(defalias alias src alias-attrs)
(defalias alias src alias-attrs alias-body)

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

Source var's metadata will be preserved (docstring, arglists, etc.). Changes to Clj source var's value will also be applied to alias. See also defaliases.

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

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

defaliasesclj/smacro

(defaliases {:keys [alias src attrs body]} ...)

Bulk version of defalias. Takes source symbols or {:keys [alias src attrs body]} 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 body]} 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 ?docstring ?attrs-map init-expr)

Like core/defonce but supports docstring and attrs map.

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

defstubclj/smacro

(defstub stub-sym)
(defstub stub-sym & more)

Experimental, subject to change without notice!! 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). Useful for defining vars in a shared ns from elsewhere (e.g. a private or cyclic ns).

Experimental, subject to change without notice!!
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).
Useful for defining vars in a shared ns from elsewhere (e.g. a private
or cyclic ns).
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)

dissoc-inclj/s

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

distinct-elements?clj/s

(distinct-elements? x)

doto-condclj/smacro

(doto-cond [sym x] & clauses)

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

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

editable?clj/s

(editable? x)

encore-versionclj/s

See assert-min-encore-version

See `assert-min-encore-version`
raw docstring

ensure-setclj/s

(ensure-set x)

ensure-vecclj/s

(ensure-vec x)

error?clj/s

(error? x)

Returns true iff given platform error (Throwable or js/Error).

Returns true iff given platform error (`Throwable` or `js/Error`).
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

file-resources-modified?clj

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

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

filter-keysclj/s

(filter-keys key-pred m)

Returns given ?map, retaining only keys for which (key-pred <key>) is truthy.

Returns given ?map, retaining only keys for which (key-pred <key>) is truthy.
raw docstring

filter-valsclj/s

(filter-vals val-pred m)

Returns given ?map, retaining only keys for which (val-pred <val>) is truthy.

Returns given ?map, retaining only keys for which (val-pred <val>) is truthy.
raw docstring

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-7 arity only. For Cljs: same as core/memoize.

For Clj: fastest possible memoize. Non-racey, 0-7 arity only.
For Cljs: same as `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-instclj/s

(format-inst inst)

Takes a platform instant (java.time.Instant or js/Date) and returns a formatted human-readable string in ISO8601 format (YYYY-MM-DDTHH:mm:ss.sssZ), e.g. "2011-12-03T10:15:130Z".

Takes a platform instant (`java.time.Instant` or `js/Date`) and
returns a formatted human-readable string in `ISO8601` format
(`YYYY-MM-DDTHH:mm:ss.sssZ`), e.g. "2011-12-03T10:15:130Z".
raw docstring

format-inst-fnclj/s≠

clj
(format-inst-fn)
(format-inst-fn {:keys [formatter zone]
                 :or {formatter java.time.format.DateTimeFormatter/ISO_INSTANT
                      zone java.time.ZoneOffset/UTC}})
cljs
(format-inst-fn)
(format-inst-fn {:keys [formatter]})

Experimental, subject to change without notice.

Returns a (fn format [instant]) that:

  • Takes a platform instant (java.time.Instant or js/Date).
  • Returns a formatted human-readable instant string.

Options: :formatter Clj: java.time.format.DateTimeFormatter Cljs: goog.i18n.DateTimeFormat

Defaults to `ISO8601` formatter (`YYYY-MM-DDTHH:mm:ss.sssZ`),
e.g.: "2011-12-03T10:15:130Z".

:zone (Clj only) java.time.ZoneOffset (defaults to UTC). Note that zone may be ignored by some DateTimeFormatters, including the default (DateTimeFormatter/ISO_INSTANT)!

Experimental, subject to change without notice.

Returns a (fn format [instant]) that:
  - Takes a platform instant (`java.time.Instant` or `js/Date`).
  - Returns a formatted human-readable instant string.

Options:
  `:formatter`
    Clj:  `java.time.format.DateTimeFormatter`
    Cljs: `goog.i18n.DateTimeFormat`

    Defaults to `ISO8601` formatter (`YYYY-MM-DDTHH:mm:ss.sssZ`),
    e.g.: "2011-12-03T10:15:130Z".

  `:zone` (Clj only) `java.time.ZoneOffset` (defaults to UTC).
   Note that zone may be ignored by some `DateTimeFormatter`s,
   including the default (`DateTimeFormatter/ISO_INSTANT`)!
raw docstring

format-nsecsclj/s

(format-nsecs nanosecs)

Returns given nanoseconds (long) as formatted human-readable string. Example outputs: "1.00m", "4.20s", "340ms", "822μs", etc.

Returns given nanoseconds (long) as formatted human-readable string.
Example outputs: "1.00m", "4.20s", "340ms", "822μs", etc.
raw docstring

format-query-stringclj/s

(format-query-string m)

future*clj/smacro

(future* form)
(future* executor-service form)

Experimental, subject to change without notice! Like future but supports use of given custom java.util.concurrent.ExecutorService.

Will default to using JVM 21+ virtual threads when possible, otherwise an unbounded fixed daemon thread pool.

See also future-call, virtual-executor, pool-executor.

Experimental, subject to change without notice!
Like `future` but supports use of given custom
`java.util.concurrent.ExecutorService`.

Will default to using JVM 21+ virtual threads when possible,
otherwise an unbounded fixed daemon thread pool.

See also `future-call`, `virtual-executor`, `pool-executor`.
raw docstring

future-call*clj

(future-call* f)
(future-call* executor-service f)

Experimental, subject to change without notice! Like future-call but supports use of given custom java.util.concurrent.ExecutorService.

Will default to using JVM 21+ virtual threads when possible, otherwise an unbounded fixed daemon thread pool.

See also future, virtual-executor, pool-executor.

Experimental, subject to change without notice!
Like `future-call` but supports use of given custom
`java.util.concurrent.ExecutorService`.

Will default to using JVM 21+ virtual threads when possible,
otherwise an unbounded fixed daemon thread pool.

See also `future`, `virtual-executor`, `pool-executor`.
raw docstring

future-poolclj

(future-pool n-threads)

Returns a simple semaphore-limited wrapper of Clojure's standard future: (fn future-pool-fn ([f] [timeout-msecs timeout-val f] [] [timeout-msecs timeout-val]))

Arities of returned function: [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-msecs timeout-val f] - Variant of [f] with timeout
[timeout-msecs timeout-val  ] - Variant of [ ] with timeout

See also future* for fully custom pools, etc.

Returns a simple semaphore-limited wrapper of Clojure's standard `future`:
  (fn future-pool-fn
    ([f] [timeout-msecs timeout-val f] [] [timeout-msecs timeout-val]))

  Arities of returned function:
    [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-msecs timeout-val f] - Variant of [f] with timeout
    [timeout-msecs timeout-val  ] - Variant of [ ] with timeout

See also `future*` for fully custom pools, etc.
raw docstring

get*clj/smacro

(get* m k)
(get* m k not-found)
(get* m k1 k2 not-found)
(get* m k1 k2 k3 not-found)

Macro version of get that:

  1. Avoids unnecessary evaluation of not-found. Useful when not-found is expensive or contains side-effects.

  2. Supports multiple prioritized keys (k1, k2, etc.). Returns val for first key that exists in map. Useful for key aliases or fallbacks.

Equivalent to: (cond (contains? m k1) (get m k1) (contains? m k2) (get m k2) ... :else not-found)

Macro version of `get` that:

  1. Avoids unnecessary evaluation of `not-found`.
     Useful when `not-found` is expensive or contains side-effects.

  2. Supports multiple prioritized keys (k1, k2, etc.). Returns val for
     first key that exists in map. Useful for key aliases or fallbacks.

Equivalent to:
  (cond
    (contains? m k1) (get m k1)
    (contains? m k2) (get m k2)
    ...
    :else            not-found)
raw docstring

get-envclj/smacro

(get-env {:keys [as default return] :or {as :str return :value}} spec)

Flexible cross-platform environmental value util.

Given a compile-time id (keyword/string) or vector of desc-priority ids, parse and return the first of the following that exists, or nil:

  1. JVM property value for id
  2. Environment variable value for id
  3. Classpath resource content for id

Ids may include optional platform tag for auto replacement, e.g.: <.platform> -> ".clj", ".cljs", or nil

Clj/s: if resulting value is a single symbol, it will be evaluated. Cljs: resulting value will be embedded in code during macro expansion!

Options: :as - Parse encountered value as given type ∈ #{:str :bool :edn} (default :str). :default - Fallback to return unparsed if no value found during search (default nil). :return - Return type ∈ #{:value :map :explain} (default :value). Use :explain to verify/debug, handy for tests/REPL!

Example: (get-env {:as :edn} [:my-app/id1<.platform> :my-app/id2]) will parse and return the first of the following that exists, or nil:

id1 with platform:
  `my-app.id1.clj` JVM         property value
  `MY_APP_id1_CLJ` environment variable value
  `my-app.id1.clj` classpath   resource content

id1 without platform:
  `my-app.id1`     JVM         property value
  `MY_APP_id1`     environment variable value
  `my-app.id1`     classpath   resource content

id2 with    platform: ...
id2 without platform: ...
Flexible cross-platform environmental value util.

Given a compile-time id (keyword/string) or vector of desc-priority
ids, parse and return the first of the following that exists, or nil:
  1. JVM         property value   for id
  2. Environment variable value   for id
  3. Classpath   resource content for id

Ids may include optional platform tag for auto replacement, e.g.:
  `<.platform>` -> ".clj", ".cljs", or nil

Clj/s: if resulting value is a single symbol, it will be evaluated.
Cljs:     resulting value will be embedded in code during macro expansion!

Options:
  `:as`      - Parse encountered value as given type ∈ #{:str :bool :edn}  (default `:str`).
  `:default` - Fallback to return unparsed if no value found during search (default `nil`).
  `:return`  - Return type ∈ #{:value :map :explain} (default `:value`).
               Use `:explain` to verify/debug, handy for tests/REPL!

Example:
  (get-env {:as :edn} [:my-app/id1<.platform> :my-app/id2]) will parse
  and return the first of the following that exists, or nil:

    id1 with platform:
      `my-app.id1.clj` JVM         property value
      `MY_APP_id1_CLJ` environment variable value
      `my-app.id1.clj` classpath   resource content

    id1 without platform:
      `my-app.id1`     JVM         property value
      `MY_APP_id1`     environment variable value
      `my-app.id1`     classpath   resource content

    id2 with    platform: ...
    id2 without platform: ...
raw docstring

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-in*clj/smacro

(get-in* m ks)
(get-in* m ks not-found)

Private, don't use this. Micro-optimized macro version of core/get-in. Avoids unnecessary evaluation of not-found.

Private, don't use this. Micro-optimized macro version of `core/get-in`.
Avoids unnecessary evaluation of `not-found`.
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 macro-form-or-meta macro-env)

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

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

get-win-loccljs

(get-win-loc)

Returns current window location as {:keys [href protocol hostname host pathname search hash]}.

Returns current window location as
{:keys [href protocol hostname host pathname search hash]}.
raw docstring

get1clj/s

(get1 m k)
(get1 m k not-found)
(get1 m k1 k2 not-found)
(get1 m k1 k2 k3 not-found)

Like get but returns val for first key that exists in map. Useful for key aliases or fallbacks. See also get*.

Like `get` but returns val for first key that exists in map.
Useful for key aliases or fallbacks. See also `get*`.
raw docstring

have-core-async?clj/s

Is clojure.core.async present (not necessarily loaded)?

Is `clojure.core.async` present (not necessarily loaded)?
raw docstring

hex-ident-strclj

(hex-ident-str obj)

Returns hex string of given Object's identityHashCode (e.g. "5eeb49f2").

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

hex-str->baclj

(hex-str->ba s)

Returns hex string for given byte[].

Returns hex string for given byte[].
raw docstring

host-infoclj

(host-info)
(host-info fallback-val)
(host-info timeout-msecs fallback-val)
(host-info cache-msecs timeout-msecs fallback-val)

Returns ?{:keys [ip name]} with string vals or fallback-val (default nil). Arities 0 and 3 are cached, prefer these! Arities 1 and 2 are uncached and intended for advanced users only.

Returns ?{:keys [ip name]} with string vals or `fallback-val` (default nil).
Arities 0 and 3 are   cached, prefer these!
Arities 1 and 2 are uncached and intended for advanced users only.
raw docstring

host-ipclj

(host-ip)
(host-ip fallback-val)
(host-ip timeout-msecs fallback-val)
(host-ip cache-msecs timeout-msecs fallback-val)

Returns local host IP string or fallback-val (default nil). Arities 0 and 3 are cached, prefer these! Arities 1 and 2 are uncached and intended for advanced users only.

Returns local host IP string or `fallback-val` (default nil).
Arities 0 and 3 are   cached, prefer these!
Arities 1 and 2 are uncached and intended for advanced users only.
raw docstring

hostnameclj

(hostname)
(hostname fallback-val)
(hostname timeout-msecs fallback-val)
(hostname cache-msecs timeout-msecs fallback-val)

Returns local hostname string or fallback-val (default nil). Arities 0 and 3 are cached, prefer these! Arities 1 and 2 are uncached and intended for advanced users only.

Returns local hostname string or `fallback-val` (default nil).
Arities 0 and 3 are   cached, prefer these!
Arities 1 and 2 are uncached and intended for advanced users only.
raw docstring

ident?clj/s

(ident? x)

identical-kw?clj/smacro

(identical-kw? x y)

Returns true iff two keywords are identical. Portable and maximally fast. For Clj this expands to: (identical? x y) For Cljs this expands to: (keyword-identical? x y)

Returns true iff two keywords are identical.
Portable and maximally fast.
  For Clj  this expands to: `(identical?         x y)`
  For Cljs this expands to: `(keyword-identical? x y)`
raw docstring

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)

Supersets core/if-let functionality. Like core/if-let but supports multiple bindings, and unconditional bindings with :let:

(if-let [x (rand-nth [:x1 :x2 false nil ]) ; Bind truthy x, or -> else :let [y (rand-nth [:y1 :y2 false nil x ])] ; Bind any y z (rand-nth [:z1 :z2 false nil x y]) ; Bind truthy z, or -> else ] [:then-clause x y z] [:else-clause])

Supersets `core/if-let` functionality. Like `core/if-let` but supports multiple
bindings, and unconditional bindings with `:let`:

(if-let [x       (rand-nth [:x1 :x2 false nil    ])  ; Bind truthy x, or -> `else`
         :let [y (rand-nth [:y1 :y2 false nil x  ])] ; Bind any    y
         z       (rand-nth [:z1 :z2 false nil x y])  ; Bind truthy z, or -> `else`
         ]
  [:then-clause x y z]
  [:else-clause])
raw docstring

if-notclj/smacro

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

Supersets core/if-not functionality. Same as encore/if-let with then andelse` forms swapped.

Supersets `core/if-not` functionality.
Same as `encore/if-let` with `then` `and `else` forms swapped.
raw docstring

if-someclj/smacro

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

Supersets core/if-some functionality. Like core/if-some but supports multiple bindings, and unconditional bindings with :let:

(if-some [x (rand-nth [:x1 :x2 false nil ]) ; Bind non-nil x, or -> else :let [y (rand-nth [:y1 :y2 false nil x ])] ; Bind any y z (rand-nth [:z1 :z2 false nil x y]) ; Bind non-nil z, or -> else ] [:then-clause x y z] [:else-clause])

Supersets `core/if-some` functionality. Like `core/if-some` but supports multiple
bindings, and unconditional bindings with `:let`:

(if-some [x       (rand-nth [:x1 :x2 false nil    ])  ; Bind non-nil x, or -> `else`
          :let [y (rand-nth [:y1 :y2 false nil x  ])] ; Bind any     y
          z       (rand-nth [:z1 :z2 false nil x y])  ; Bind non-nil z, or -> `else`
          ]
  [:then-clause x y z]
  [:else-clause])
raw docstring

indexed?clj/s

(indexed? x)

inst->udtclj/s≠

(inst->udt inst)
clj

Returns given java.time.Instant as milliseconds since Unix epoch.

Returns given `java.time.Instant` as milliseconds since Unix epoch.
cljs

Returns given js/Date as milliseconds since Unix epoch.

Returns given `js/Date` as milliseconds since Unix epoch.
raw docstring

inst?clj/s

(inst? x)

Returns true iff given platform instant (java.time.Instant or js/Date).

Returns true iff given platform instant (`java.time.Instant` or `js/Date`).
raw docstring

instance!clj/smacro

(instance! class arg)
(instance! class arg {:keys [msg context param ...]})
(instance! class arg & {:keys [msg context param ...]})

If (instance? class arg) is true, returns arg. Otherwise throws runtime ex-info.

If (instance? class arg) is true, returns arg.
Otherwise throws runtime ex-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)

Like interleave but includes all items (i.e. stops when the longest rather than shortest coll has been consumed).

Like `interleave` but includes all items (i.e. stops when the longest
rather than shortest coll has been consumed).
raw docstring

interns-overviewclj

(interns-overview)
(interns-overview ns)

Returns {:keys [api public private impl test no-doc]}, 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 [api public private impl test no-doc]}, 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!)
(into! to! from)
(into! to! xform from)

Like into but assumes to! is a transient, and doesn't call persist! when done. Useful as a performance optimization in some cases.

Like `into` but assumes `to!` is a transient, and doesn't call
`persist!` when done. Useful as a performance optimization in some cases.
raw docstring

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)

Returns given ?map with keys and vals inverted, dropping non-unique vals!

Returns given ?map with keys and vals inverted, dropping non-unique vals!
raw docstring

invert-map!clj/s

(invert-map! m)

Like invert-map but throws on non-unique vals.

Like `invert-map` but throws on non-unique vals.
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)

java-versionclj

(java-version)
(java-version version-string)

Returns Java's major version integer (8, 17, etc.).

Returns Java's major version integer (8, 17, etc.).
raw docstring

java-version>=clj

(java-version>= n)

Returns true iff Java's major version integer is >= given integer: (if (java-version>= 21) <then> <else>)

Returns true iff Java's major version integer is >= given integer:
(if (java-version>= 21) <then> <else>)
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

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)

lazy-seq?clj/s

(lazy-seq? x)

logcljs


logfcljs

(logf fmt & xs)

logpcljs

(logp & xs)

map-entryclj/s

(map-entry k v)

Returns a MapEntry with given key and value.

Returns a `MapEntry` with given key and value.
raw docstring

map-keysclj/s

(map-keys key-fn m)

Returns given ?map with (key-fn <key>) keys.

Returns given ?map with (key-fn <key>) keys.
raw docstring

map-valsclj/s

(map-vals val-fn m)

Returns given ?map with (val-fn <val>) vals.

Returns given ?map with (val-fn <val>) vals.
raw docstring

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-lastclj/s

(memoize-last f)

Like core/memoize but only caches the given fn's latest input. Speeds repeated fn calls with the same arguments. Great for ReactJS render fn caching, etc.

Like `core/memoize` but only caches the given fn's latest input.
Speeds repeated fn calls with the same arguments.
Great for ReactJS render fn caching, etc.
raw docstring

mergeclj/s

(merge)
(merge m1)
(merge m1 m2)
(merge m1 m2 m3)
(merge m1 m2 m3 & more)

Like core/merge but:

  • Supports :merge/dissoc vals.
  • Often faster, with much better worst-case performance.
Like `core/merge` but:
- Supports `:merge/dissoc` vals.
- Often faster, with much better worst-case performance.
raw docstring

merge-metaclj/s

(merge-meta x m)

merge-nxclj/s

(merge-nx)
(merge-nx m1)
(merge-nx m1 m2)
(merge-nx m1 m2 m3)
(merge-nx m1 m2 m3 & more)

Like core/merge but:

  • Preserves existing values, e.g. (merge-nx <user-opts> <defaults>).
  • Supports :merge/dissoc vals.
  • Often faster, with much better worst-case performance.
Like `core/merge` but:
- Preserves existing values, e.g. (merge-nx <user-opts> <defaults>).
- Supports `:merge/dissoc` vals.
- Often faster, with much better worst-case performance.
raw docstring

merge-url-with-query-stringclj/s

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

merge-withclj/s

(merge-with f)
(merge-with f m1)
(merge-with f m1 m2)
(merge-with f m1 m2 m3)
(merge-with f m1 m2 m3 & more)

Like core/merge-with but:

  • Supports :merge/dissoc vals.
  • Often faster, with much better worst-case performance.
Like `core/merge-with` but:
- Supports `:merge/dissoc` vals.
- Often faster, with much better worst-case performance.
raw docstring

min*clj/smacro

(min* n1 n2)

min-longclj/s


msclj/s

(ms opts)
(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)
(msecs & {:as opts :keys [years months weeks days hours mins secs msecs ms]})

Macro version of ms.

Macro version of `ms`.
raw docstring

name-filterclj/s

(name-filter spec)

Given filter spec, returns a compiled (fn match? [x]) that:

  • Takes a string, keyword, symbol, or namespace.
  • Returns true iff input matches spec.

Useful for efficiently filtering namespaces, class names, id kws, etc.

Spec may be:

  • A namespace to match exactly

  • A regex pattern to match

  • A str/kw/sym to match, with "" and "(.)" as wildcards: "foo." will match "foo.bar" "foo(.)" will match "foo.bar" and "foo" If you need literal "*"s, use #"*" regex instead.

  • A set/vector of the above to match any

  • A map, {:allow <spec> :disallow <spec>} with specs as the above: If present, :allow spec MUST match, AND If present, :disallow spec MUST NOT match.

Spec examples: ns, #{}, "", "foo.bar", "foo.bar.", "foo.bar(.)", #{"foo" "bar."}, #"(foo1|foo2).bar", {:allow #{"foo" "bar."} :disallow #{"foo..bar.*"}}.

Given filter `spec`, returns a compiled (fn match? [x]) that:
  - Takes a string, keyword, symbol, or namespace.
  - Returns true iff input matches spec.

Useful for efficiently filtering namespaces, class names, id kws, etc.

Spec may be:
  - A namespace     to match exactly
  - A regex pattern to match
  - A str/kw/sym    to match, with "*" and "(.*)" as wildcards:
    "foo.*"   will match "foo.bar"
    "foo(.*)" will match "foo.bar" and "foo"
    If you need literal "*"s, use #"\*" regex instead.

  - A set/vector of the above to match any
  - A map, {:allow <spec> :disallow <spec>} with specs as the above:
    If present,    `:allow` spec MUST     match, AND
    If present, `:disallow` spec MUST NOT match.

Spec examples:
  *ns*, #{}, "*", "foo.bar", "foo.bar.*", "foo.bar(.*)",
  #{"foo" "bar.*"}, #"(foo1|foo2)\.bar",
  {:allow #{"foo" "bar.*"} :disallow #{"foo.*.bar.*"}}.
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

nameable?clj/s

(nameable? x)

named?clj/s

(named? x)

nanoidclj/s≠

clj
(nanoid)
(nanoid len)
(nanoid secure? len)
cljs
(nanoid)
(nanoid len)
(nanoid prefer-secure? len)

Returns a random "Nano ID" of given length, Ref. https://github.com/ai/nanoid. Faster, variable-length version of (rand-id-fn {:chars :nanoid}). 126 bits of entropy with default length (21). See also uuid-str, rand-id-fn.

Returns a random "Nano ID" of given length, Ref. <https://github.com/ai/nanoid>.
Faster, variable-length version of (rand-id-fn {:chars :nanoid}).
126 bits of entropy with default length (21).
See also `uuid-str`, `rand-id-fn`.
raw docstring

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)
(nested-merge m1)
(nested-merge m1 m2)
(nested-merge m1 m2 m3)
(nested-merge m1 m2 m3 & more)

Like core/merge but:

  • Recursively merges nested maps.
  • Supports :merge/dissoc vals.
  • Often faster, with much better worst-case performance.
Like `core/merge` but:
- Recursively merges nested maps.
- Supports `:merge/dissoc` vals.
- Often faster, with much better worst-case performance.
raw docstring

nested-merge-withclj/s

(nested-merge-with f)
(nested-merge-with f m1)
(nested-merge-with f m1 m2)
(nested-merge-with f m1 m2 m3)
(nested-merge-with f m1 m2 m3 & more)

Like core/merge-with but:

  • Recursively merges nested maps.
  • Supports :merge/dissoc vals.
  • Often faster, with much better worst-case performance.
Like `core/merge-with` but:
- Recursively merges nested maps.
- Supports `:merge/dissoc` vals.
- Often faster, with much better worst-case performance.
raw docstring

new-objectclj/smacro

(new-object)

newlineclj/s

Single system newline

Single system newline
raw docstring

newlinesclj/s

Double system newline

Double system newline
raw docstring

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

norm-strclj/s

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

Returns normalized form of given string. norm-form is ∈ #{:nfc :nfkc :nfd :nfkd} (default :nfc as per W3C).

Returns normalized form of given string.
`norm-form` is ∈ #{:nfc :nfkc :nfd :nfkd} (default `:nfc` as per W3C).
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)

not-empty-collclj/s

(not-empty-coll x)

now-dtclj/s≠

(now-dt)
clj

Returns current system instant as java.util.Date.

Returns current system instant as `java.util.Date`.
cljs

Returns current system instant as js/Date.

Returns current system instant as `js/Date`.
raw docstring

now-instclj/s≠

(now-inst)
clj

Returns current system instant as java.time.Instant.

Returns current system instant as `java.time.Instant`.
cljs

Returns current system instant as js/Date.

Returns current system instant as `js/Date`.
raw docstring

now-nanoclj/s≠

clj
(now-nano)
cljs

Returns current value of best-resolution time source as nanoseconds.

Returns current value of best-resolution time source as nanoseconds.
raw docstring

now-udtclj/s≠

(now-udt)
clj

Returns current system instant as milliseconds since Unix epoch.

Returns current system instant as milliseconds since Unix epoch.
cljs

Returns current system insant as milliseconds since Unix epoch.

Returns current system insant as milliseconds since Unix epoch.
raw docstring

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, subject to change without notice. Like assoc-in for JS objects.

Experimental, subject to change without notice.
Like `assoc-in` for JS objects.
raw docstring

parse-js-intcljs

(parse-js-int 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)

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

pool-executorclj

(pool-executor {:keys [n-threads n-min-threads n-max-threads thread-name-prefix
                       daemon-threads? keep-alive-msecs queue-type queue-size]
                :or {n-threads (+ 2 (get-num-threads [:ratio 1.0]))
                     thread-name-prefix "com.taoensso/encore-pool-"
                     daemon-threads? true
                     keep-alive-msecs 60000
                     queue-type :linked}})

Experimental, subject to change without notice! Returns new java.util.concurrent.ThreadPoolExecutor with given opts.

Experimental, subject to change without notice!
Returns new `java.util.concurrent.ThreadPoolExecutor` with given opts.
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)

prclj/s≠

clj
(pr & args)

Like core/pr but faster, and atomic (avoids interleaved content from different threads).

Like `core/pr` but faster, and atomic (avoids interleaved content from different threads).
cljs

Identical to core/pr.

Identical to `core/pr`.
raw docstring

pr-ednclj/s

(pr-edn x)

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

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

pr-jsoncljs

(pr-json x)

Returns given Cljs argument as JSON string.

Returns given Cljs argument as JSON string.
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)

Public version of core/preserving-reduced.

Public version of `core/preserving-reduced`.
raw docstring

printclj/s≠

clj
(print & args)

Like core/print but faster, and atomic (avoids interleaved content from different threads).

Like `core/print` but faster, and atomic (avoids interleaved content from different threads).
cljs

Identical to core/print.

Identical to `core/print`.
raw docstring

printlnclj/s≠

clj
(println & args)

Like core/println but faster, and atomic (avoids interleaved content from different threads).

Like `core/println` but faster, and atomic (avoids interleaved content from different threads).
cljs

Identical to core/println.

Identical to `core/println`.
raw docstring

prnclj/s≠

clj
(prn & args)

Like core/prn but faster, and atomic (avoids interleaved content from different threads).

Like `core/prn` but faster, and atomic (avoids interleaved content from different threads).
cljs

Identical to core/prn.

Identical to `core/prn`.
raw docstring

pull-val!clj/s

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

Removes and returns value mapped to key: (let [a (atom {:k :v})] [(pull-val! a :k) @a]) => [:v {}]

Removes and returns value mapped to key:
(let [a (atom {:k :v})]
  [(pull-val! a :k) @a]) => [:v {}]
raw docstring

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

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 new PersistentQueue.

Returns a new `PersistentQueue`.
raw docstring

queue*clj/s

(queue* & items)

Returns a new PersistentQueue given items.

Returns a new `PersistentQueue` given items.
raw docstring

queue?clj/s

(queue? x)

Returns true iff given a PersistentQueue.

Returns true iff given a `PersistentQueue`.
raw docstring

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

rand-bytesclj/s≠

clj
(rand-bytes secure? size)
cljs
(rand-bytes prefer-secure? size)

Returns a random byte array of given size.

Returns a random byte array of given size.
raw docstring

rand-id-fnclj/s

(rand-id-fn {:keys [chars len rand-bytes-fn]
             :or
               {chars :nanoid len 21 rand-bytes-fn (partial rand-bytes true)}})

Returns a (fn rand-id []) that returns random id strings. Options include: :chars - ∈ #{<string> :nanoid :alphanumeric :no-look-alikes ...} :len - Length of id strings to generate :rand-bytes-fn - Optional (fn [size]) to return random byte array of given size

See also uuid-str, nano-id.

Returns a (fn rand-id []) that returns random id strings.
Options include:
  `:chars`         - ∈ #{<string> :nanoid :alphanumeric :no-look-alikes ...}
  `:len`           - Length of id strings to generate
  `:rand-bytes-fn` - Optional (fn [size]) to return random byte array of given size

See also `uuid-str`, `nano-id`.
raw docstring

rate-limiterclj/s

(rate-limiter spec)
(rate-limiter opts spec)

Takes a spec of form [ [<n-max-reqs> <msecs-window>] ...] or ; Unnamed limits {<limit-id> [<n-max-reqs> <msecs-window>]} ; Named limits and returns stateful (fn a-rate-limiter [] [req-id] [command req-id]).

Call the returned limiter fn with a request id (any Clojure value!) to enforce limits independently for each id.

For example, (limiter-fn <ip-address-string>) will return:

  • Falsey when allowed (all limits pass for given IP), or
  • Truthy when disallowed (any limits fail for given IP): [<worst-limit-id> <worst-backoff-msecs> {<limit-id> <backoff-msecs>}]

Or call the returned limiter fn with an extra command argument: (limiter-fn :rl/peek <req-id) - Check limits WITHOUT incrementing count (limiter-fn :rl/reset <req-id) - Reset all limits for given req-id

Takes a spec of form
  [           [<n-max-reqs> <msecs-window>] ...] or ; Unnamed limits
  {<limit-id> [<n-max-reqs> <msecs-window>]}        ;   Named limits
and returns stateful (fn a-rate-limiter [] [req-id] [command req-id]).

Call the returned limiter fn with a request id (any Clojure value!) to
enforce limits independently for each id.

For example, (limiter-fn <ip-address-string>) will return:
  - Falsey when    allowed (all limits pass for given IP), or
  - Truthy when disallowed (any limits fail for given IP):
    [<worst-limit-id> <worst-backoff-msecs> {<limit-id> <backoff-msecs>}]

Or call the returned limiter fn with an extra command argument:
  (limiter-fn :rl/peek  <req-id) - Check limits WITHOUT incrementing count
  (limiter-fn :rl/reset <req-id) - Reset all limits for given req-id
raw docstring

rcompareclj/s

(rcompare x y)

Reverse comparator.

Reverse comparator.
raw docstring

re-pattern?clj/s

(re-pattern? x)

read-ednclj/s≠

clj
(read-edn s)
(read-edn {:keys [readers default]
           :as opts
           :or {readers clojure.core/*data-readers*
                default clojure.core/*default-data-reader-fn*}})
cljs
(read-edn s)
(read-edn {:keys [readers default]
           :as opts
           :or {readers (clojure.core/deref cljs.reader/*tag-table*)
                default (clojure.core/deref
                          cljs.reader/*default-data-reader-fn*)}})

Reads given edn string to return a Clj/s value.

Reads given edn string to return a Clj/s value.
raw docstring

read-jsoncljs

(read-json s)
(read-json kw-keys? s)

Reads given JSON string to return a Cljs value.

Reads given JSON string to return a Cljs value.
raw docstring

reassoc-someclj/s

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

Assocs each kv to given ?map if its value is nil, otherwise dissocs it.

Assocs each kv to given ?map if its value is nil, otherwise dissocs it.
raw docstring

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-interleave-allclj/s

(reduce-interleave-all rf init colls)

Reduces sequence of elements interleaved from given colls. (reduce-interleave-all conj [] [[:a :b] [1 2 3]]) => [:a 1 :b 2 3]

Reduces sequence of elements interleaved from given `colls`.
(reduce-interleave-all conj [] [[:a :b] [1 2 3]]) => [:a 1 :b 2 3]
raw docstring

reduce-iterator!clj

(reduce-iterator! rf init iterator)

Reduces given java.util.Iterator, mutating it. Note that most colls providing iterators implement java.lang.Iterable, so support seq directly.

Reduces given `java.util.Iterator`, mutating it. Note that most colls
providing iterators implement `java.lang.Iterable`, so support `seq` directly.
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-multiclj/s

(reduce-multi rf init coll)
(reduce-multi rf1 init1 rf2 init2 coll)
(reduce-multi rf1 init1 rf2 init2 rf3 init3 coll)

Like reduce but supports separate simultaneous accumulators as a micro-optimization when reducing a large collection multiple times.

Like `reduce` but supports separate simultaneous accumulators
as a micro-optimization when reducing a large collection multiple
times.
raw docstring

reduce-nclj/s≠

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

No longer useful with Clojure 1.7+, just use (reduce f init (range ...)).

No longer useful with Clojure 1.7+, just use (reduce f init (range ...)).
raw docstring

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)
(reduce-zip rf init xs ys not-found)

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

remove-keysclj/s

(remove-keys key-pred m)

Returns given ?map, removing keys for which (key-pred <key>) is truthy.

Returns given ?map, removing keys for which (key-pred <key>) is truthy.
raw docstring

remove-valsclj/s

(remove-vals val-pred m)

Returns given ?map, removing keys for which (val-pred <val>) is truthy.

Returns given ?map, removing keys for which (val-pred <val>) is truthy.
raw docstring

rename-keysclj/s

(rename-keys replacements m)

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

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

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

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. Returns <old-key-val>.

Like `reset-in!` but optimized for single-key case. Returns <old-key-val>.
raw docstring

reset-val!?clj/s

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

Like reset-in!? but optimized for single-key case. Returns true iff the atom's value changed.

Like `reset-in!?` but optimized for single-key case.
Returns true iff the atom's value changed.
raw docstring

revery-kv?clj/s

(revery-kv? pred coll)

Returns true iff (pred k v) is truthy for every kv in associative coll.

Returns true iff (pred k v) is truthy for every kv in associative coll.
raw docstring

revery?clj/s

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

Returns true iff (pred x) is truthy for every x in coll. Like core/every? but faster and supports transducers.

Returns true iff (pred x) is truthy for every x in coll.
Like `core/every?` but faster and supports transducers.
raw docstring

rfirstclj/s

(rfirst pred coll)
(rfirst xform pred coll)

Returns nil, or first x in coll with truthy (pred x).

Returns nil, or first x in coll with truthy (pred x).
raw docstring

rfirst-kvclj/s

(rfirst-kv pred coll)

Returns nil, or first [k v] entry in associative coll with truthy (pred k v).

Returns nil, or first [k v] entry in associative coll with truthy (pred k v).
raw docstring

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, subject to change without notice. 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, subject to change without notice.
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: [ ] => Returns current array in O(n). [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:
  [ ] => Returns current array in O(n).
  [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: [ ] => Returns current sub/vector in O(1). [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:
  [ ] => Returns current sub/vector in O(1).
  [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)
(round kind n)
(round kind precision n)

General purpose rounding util. Returns given number n rounded according to given options:

  • kind - ∈ #{:round :floor :ceil :trunc} (default :round)
  • precision - Number of decimal places to include (default nil => none)
General purpose rounding util.
Returns given number `n` rounded according to given options:
  - `kind`      - ∈ #{:round :floor :ceil :trunc}     (default `:round`)
  - `precision` - Number of decimal places to include (default `nil` => none)
raw docstring

round0clj/s

(round0 n)

round1clj/s

(round1 n)

round2clj/s

(round2 n)

round3clj/s

(round3 n)

round4clj/s

(round4 n)

roundnclj/s

(roundn precision n)

rsomeclj/s

(rsome pred coll)
(rsome xform pred coll)

Returns nil, or first truthy (pred x) for x in coll. Like core/some but faster and supports transducers.

Returns nil, or first truthy (pred x) for x in coll.
Like `core/some` but faster and supports transducers.
raw docstring

rsome-kvclj/s

(rsome-kv pred coll)

Returns nil, or first truthy (pred k v) for kv in associative coll. Like core/some but faster and takes kvs.

Returns nil, or first truthy (pred k v) for kv in associative coll.
Like `core/some` but faster and takes kvs.
raw docstring

run!clj/s

(run! proc coll)

run-kv!clj/s

(run-kv! proc m)

run-kvs!clj/s

(run-kvs! proc kvs)

run-obj!cljs

(run-obj! proc obj)

runnerclj

(runner {:as opts
         :keys [mode buffer-size n-threads thread-name drain-msecs auto-stop?
                convey-bindings? daemon-threads?]
         :or {mode :blocking
              buffer-size 1024
              n-threads 1
              drain-msecs 6000
              auto-stop? true
              convey-bindings? true
              daemon-threads? true}})

Experimental, subject to change without notice! Returns a new stateful "runner" such that:

(runner f) ; Arity 1 call Requests runner to execute given nullary fn according to runner's opts. Returns: - true if runner accepted fn for execution without back-pressure. - false if runner experienced back-pressure (fn may/not execute). - nil if runner has stopped accepting new execution requests.

(deref runner) Returns a promise that will be delivered once all pending execution requests complete.

(runner) ; Arity 0 call Causes runner to permanently stop accepting new execution requests. On first call returns a promise that will be delivered once all pending execution requests complete. On subsequent calls returns nil.

Runners are a little like agents, but:

  • Take nullary fns rather than unary fns of state.
  • Have no validators or watches.
  • Have configurable back-pressure.
  • Can have >1 thread (in which case fns may execute out-of-order!).

These properties make them useful as configurable general-purpose async workers.

Options include:

:buffer-size (default 1024) Size of request buffer, and the max number of pending requests before configured back-pressure behaviour is triggered (see :mode).

:mode (default :blocking) Back-pressure mode ∈ #{:blocking :dropping :sliding}. Controls what happens when a new request is made while request buffer is full: :blocking => Blocks caller until buffer space is available :dropping => Drops the newest request (noop) :sliding => Drops the oldest request

:n-threads (default 1) Number of threads to use for executing fns (servicing request buffer). NB execution order may be non-sequential when n > 1.

:drain-msecs (default 6000 msecs) Maximum time (in milliseconds) to try allow pending execution requests to complete when stopping runner. nil => no maximum.

Experimental, subject to change without notice!
 Returns a new stateful "runner" such that:

  (runner f) ; Arity 1 call
    Requests runner to execute given nullary fn according to runner's opts.
    Returns:
      - `true`  if runner accepted fn for execution without back-pressure.
      - `false` if runner experienced back-pressure (fn may/not execute).
      - `nil`   if runner has stopped accepting new execution requests.

  (deref runner)
    Returns a promise that will be delivered once all pending execution
    requests complete.

  (runner) ; Arity 0 call
    Causes runner to permanently stop accepting new execution requests.
    On first call returns a promise that will be delivered once all pending
    execution requests complete. On subsequent calls returns nil.

Runners are a little like agents, but:
  - Take nullary fns rather than unary fns of state.
  - Have no validators or watches.
  - Have configurable back-pressure.
  - Can have >1 thread (in which case fns may execute out-of-order!).

These properties make them useful as configurable general-purpose async workers.

Options include:

  `:buffer-size` (default 1024)
    Size of request buffer, and the max number of pending requests before
    configured back-pressure behaviour is triggered (see `:mode`).

  `:mode` (default `:blocking`)
    Back-pressure mode ∈ #{:blocking :dropping :sliding}.
    Controls what happens when a new request is made while request buffer is full:
      `:blocking` => Blocks caller until buffer space is available
      `:dropping` => Drops the newest request (noop)
      `:sliding`  => Drops the oldest request

  `:n-threads` (default 1)
    Number of threads to use for executing fns (servicing request buffer).
    NB execution order may be non-sequential when n > 1.

  `:drain-msecs` (default 6000 msecs)
    Maximum time (in milliseconds) to try allow pending execution requests to
    complete when stopping runner. nil => no maximum.
raw docstring

satisfies!clj/smacro

(satisfies! protocol arg)
(satisfies! protocol arg {:keys [msg context param ...]})
(satisfies! protocol arg & {:keys [msg context param ...]})

If (satisfies? protocol arg) is true, returns arg. Otherwise throws runtime ex-info.

If (satisfies? protocol arg) is true, returns arg.
Otherwise throws runtime ex-info.
raw docstring

satisfies?clj/smacro

(satisfies? protocol x)

Faster satisfies? to work around CLJ-1814 until a proper upstream fix. May cache, so possibly inappropriate for dynamic work.

Faster `satisfies?` to work around CLJ-1814 until a proper upstream fix.
May cache, so possibly inappropriate for dynamic work.
raw docstring

sayfcljs

(sayf fmt & xs)

saypcljs

(sayp & xs)

sb-appendclj/s

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

Appends given string/s to given string builder. See also str-builder.

Appends given string/s to given string builder. See also `str-builder.`
raw docstring

sb-lengthclj/s

(sb-length sb)

Returns given string builder's current length (character count).

Returns given string builder's current length (character count).
raw docstring

secsclj/s

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

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

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

secs->msclj/s

(secs->ms secs)

secure-rngclj

(secure-rng)

Returns an auto-reseeding thread-local java.security.SecureRandom. Favours security over performance. May block while waiting on entropy!

Returns an auto-reseeding thread-local `java.security.SecureRandom`.
Favours security over performance. May block while waiting on 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

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)

Util to help correctly update Ring sessions (something easy to get wrong!).

Given a Ring request (rreq) and Ring response (rresp), returns a new Ring response with the response session updated to be (f <old-session>) or (apply f <old-session> args).

Util to help correctly update Ring sessions (something easy to get wrong!).

Given a Ring request (rreq) and Ring response (rresp), returns a new
Ring response with the response session updated to be (f <old-session>)
or (apply f <old-session> args).
raw docstring

set-var-root!clj/smacro

(set-var-root! var-sym root-val)

Sets root binding (value) of the var identified by given symbol, and returns the new value. Cross-platform. See also update-var-root!.

Sets root binding (value) of the var identified by given symbol, and returns
the new value. Cross-platform. See also `update-var-root!`.
raw docstring

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)

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)
(some= x y)
(some= x y & more)

Returns true iff given args are equal AND non-nil.

Returns true iff given args are equal AND non-nil.
raw docstring

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

str->utf8-baclj

(str->utf8-ba s)

Returns given String encoded as a UTF-8 byte[].

Returns given String encoded as a UTF-8 byte[].
raw docstring

str-?indexclj/s

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

Returns (first/last) ?index of substring if it exists within given string.

Returns (first/last) ?index of substring if it exists within given string.
raw docstring

str-builderclj/s

(str-builder)
(str-builder init)

Returns a new stateful string builder:

  • java.lang.StringBuilder for Clj
  • goog.string.StringBuffer for Cljs

See also sb-append.

Returns a new stateful string builder:
  - `java.lang.StringBuilder`  for Clj
  - `goog.string.StringBuffer` for Cljs

See also `sb-append`.
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 xs)
(str-join separator xs)
(str-join separator xform xs)

Faster generalization of clojure.string/join with transducer support.

Faster generalization of `clojure.string/join` with transducer support.
raw docstring

str-join-onceclj/s

(str-join-once separator coll)

Like string/join but skips nils and duplicate separators.

Like `string/join` but skips nils and 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

(str-rf)
(str-rf acc)
(str-rf acc in)

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)

submap?clj/s

(submap? super-map sub-map)

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

sub-map may contain special values: :submap/nx - Matches iff super-map does not contain key :submap/ex - Matches iff super-map does contain key (any val) :submap/some - Matches iff super-map does contain key (non-nil val) (fn [super-val]) - Matches iff given unary predicate returns truthy

Uses stack recursion so supports only limited nesting.

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

`sub-map` may contain special values:
  `:submap/nx`     - Matches iff `super-map` does not contain key
  `:submap/ex`     - Matches iff `super-map` does     contain key (any     val)
  `:submap/some`   - Matches iff `super-map` does     contain key (non-nil val)
  (fn [super-val]) - Matches iff given unary predicate returns truthy

Uses stack recursion so supports only limited nesting.
raw docstring

submaps?clj/s

(submaps? maps subs)

Experimental, subject to change without notice. Returns true iff sub_i is a (possibly nested) submap of m_i. Uses submap?.

Experimental, subject to change without notice.
Returns true iff `sub_i` is a (possibly nested) submap of `m_i`.
Uses `submap?`.
raw docstring

substrclj/s

(substr s start-idx)
(substr s start-idx end-idx)
(substr s :by-len start end)

Returns a non-empty sub-string, or nil. Like subs but:

  • Doesn't throw when out-of-bounds (clips to bounds).
  • Returns nil rather than an empty string.
  • When given :by-len kind (4-arity case):
    • start may be -ive (=> index from right of string).
    • end is desired string length, or :max.
Returns a non-empty sub-string, or nil.
Like `subs` but:
  - Doesn't throw when out-of-bounds (clips to bounds).
  - Returns nil rather than an empty string.
  - When given `:by-len` kind (4-arity case):
    - `start` may be -ive (=> index from right of string).
    - `end`   is desired string length, or `:max`.
raw docstring

subvecclj/s

(subvec v start-idx)
(subvec v start-idx end-idx)
(subvec v :by-len start end)

Returns a non-empty sub-vector, or nil. Like core/subvec but:

  • Doesn't throw when out-of-bounds (clips to bounds).
  • Returns nil rather than an empty vector.
  • When given :by-len kind (4-arity case):
    • start may be -ive (=> index from right of vector).
    • end is desired vector length, or :max.
Returns a non-empty sub-vector, or nil.
Like `core/subvec` but:
  - Doesn't throw when out-of-bounds (clips to bounds).
  - Returns nil rather than an empty vector.
  - When given `:by-len` kind (4-arity case):
    - `start` may be -ive (=> index from right of vector).
    - `end`   is desired vector length, or `:max`.
raw docstring

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 and swapped. Returns <new-key-val> or <swapped-return-val>: (swap-in! (atom {:k1 {:k2 5}}) [:k1 :k2] inc) => 6 (swap-in! (atom {:k1 {:k2 5}}) [:k1 :k2] (fn [old] (swapped (inc old) old))) => 5

Like `swap!` but supports `update-in` semantics and `swapped`.
Returns <new-key-val> or <swapped-return-val>:
  (swap-in! (atom {:k1 {:k2 5}}) [:k1 :k2] inc) => 6
  (swap-in! (atom {:k1 {:k2 5}}) [:k1 :k2]
    (fn [old] (swapped (inc old) old))) => 5
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. Returns <new-key-val> or <swapped-return-val>: (swap-val! (atom {:k 5}) :k inc) => 6 (swap-val! (atom {:k 5}) :k (fn [old] (swapped (inc old) old))) => 5

Like `swap-in!` but optimized for single-key case.
Returns <new-key-val> or <swapped-return-val>:
  (swap-val! (atom {:k 5}) :k inc) => 6
  (swap-val! (atom {:k 5}) :k
    (fn [old] (swapped (inc old) old))) => 5
raw docstring

swappedclj/s

(swapped new-val return-val)

For use within the swap functions of swap-in! and swap-val!.

Allows the easy decoupling of new and returned values. Compare: (let [a (atom 0)] [(core/swap! a (fn [old] (inc old) )) @a]) [1 1] ; new=1, return=1 (let [a (atom 0)] [(swap-in! a (fn [old] (swapped (inc old) old))) @a]) [0 1] ; new=1, return=0

Faster and much more flexible than core/swap-vals!, etc. Especially useful when combined with the update-in semantics of swap-in!, etc.

For use within the swap functions of `swap-in!` and `swap-val!`.

Allows the easy decoupling of new and returned values. Compare:
  (let [a (atom 0)] [(core/swap! a (fn [old]          (inc old)     )) @a]) [1 1] ; new=1, return=1
  (let [a (atom 0)] [(swap-in!   a (fn [old] (swapped (inc old) old))) @a]) [0 1] ; new=1, return=0

Faster and much more flexible than `core/swap-vals!`, etc.
Especially useful when combined with the `update-in` semantics of `swap-in!`, etc.
raw docstring

swapped?clj/s

(swapped? x)

Returns true iff given Swapped argument.

Returns true iff given `Swapped` argument.
raw docstring

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-idclj

(thread-id)

Returns long id of current Thread.

Returns long id of current `Thread`.
raw docstring

thread-infoclj

(thread-info)

Returns {:keys [group name id]} for current Thread.

Returns {:keys [group name id]} for current `Thread`.
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

thread-nameclj

(thread-name)

Returns string name of current Thread.

Returns string name of current `Thread`.
raw docstring

throwable?clj

(throwable? x)

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

transient?clj/s

(transient? x)

udt->instclj/s≠

(udt->inst msecs-since-epoch)
clj

Returns given milliseconds since Unix epoch as java.time.Instant.

Returns given milliseconds since Unix epoch as `java.time.Instant`.
cljs

Returns given milliseconds since Unix epoch as js/Date.

Returns given milliseconds since Unix epoch as `js/Date`.
raw docstring

udt?clj/s

(udt? x)

update!clj/s

(update! m k f)

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: :update/dissoc, :update/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: `:update/dissoc`, `:update/abort`.
raw docstring

update-var-root!clj/smacro

(update-var-root! var-sym update-fn)

Updates root binding (value) of the var identified by given symbol, and returns the new value: (update-var-root! my-var (fn [old-root-val] <new-root-val>)) => <new-root-val>

Similar to alter-var-root but cross-platform and takes a symbol rather than a var. See also set-var-root!.

Updates root binding (value) of the var identified by given symbol, and returns
the new value:
  (update-var-root! my-var (fn [old-root-val] <new-root-val>)) => <new-root-val>

Similar to `alter-var-root` but cross-platform and takes a symbol rather than a var.
See also `set-var-root!`.
raw docstring

uri?clj

(uri? x)

url-decodeclj/s

(url-decode s & [encoding])

Stolen from http://goo.gl/99NSR1.

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

utf8-ba->strclj

(utf8-ba->str ba)

Returns String by decoding given UTF-8 byte[].

Returns String by decoding given UTF-8 byte[].
raw docstring

uuidclj/s

(uuid)

For Clj: returns a random java.util.UUID. For Cljs: returns a random UUID string.

Uses strong randomness when possible. See also uuid-str, nanoid, rand-id-fn.

For Clj: returns a random `java.util.UUID`.
For Cljs: returns a random UUID string.

Uses strong randomness when possible.
See also `uuid-str`, `nanoid`, `rand-id-fn`.
raw docstring

uuid-strclj/s

(uuid-str)
(uuid-str max-len)

Returns a random UUID string of given length (max 36). Uses strong randomness when possible. See also uuid, nanoid, rand-id-fn.

Returns a random UUID string of given length (max 36).
Uses strong randomness when possible. See also `uuid`, `nanoid`, `rand-id-fn`.
raw docstring

vec2?clj/s

(vec2? x)

vec3?clj/s

(vec3? x)

vinterleave-allclj/s

(vinterleave-all colls)
(vinterleave-all c1 c2)
(vinterleave-all c1 c2 c3)
(vinterleave-all c1 c2 c3 & colls)

Like interleave, but:

  • Returns a vector rather than lazy seq (=> greedy).
  • Includes all items (i.e. stops when the longest rather than shortest coll has been consumed).

Single-arity version takes a coll of colls.

Like `interleave`, but:
  - Returns a vector rather than lazy seq (=> greedy).
  - Includes all items (i.e. stops when the longest rather than
    shortest coll has been consumed).

Single-arity version takes a coll of colls.
raw docstring

virtual-executorclj

(virtual-executor)

Experimental, subject to change without notice! Returns new virtual java.util.concurrent.ThreadPerTaskExecutor when possible (JVM 21+), otherwise returns nil.

Experimental, subject to change without notice!
Returns new virtual `java.util.concurrent.ThreadPerTaskExecutor` when
possible (JVM 21+), otherwise returns nil.
raw docstring

vnextclj/s

(vnext v)

vrestclj/s

(vrest v)

vsplit-firstclj/s

(vsplit-first v)

vsplit-lastclj/s

(vsplit-last v)

whenclj/smacro

(when test-or-bindings & body)

Supersets core/when and core/when-let functionality. When test-or-bindings is a vector, same as encore/when-let. Otherwise same as core/when.

Supersets `core/when` and `core/when-let` functionality. When `test-or-bindings` is
a vector, same as `encore/when-let`. Otherwise same as `core/when`.
raw docstring

when-letclj/smacro

(when-let bindings & body)

Supersets core/when-let functionality. Like core/when-let but supports multiple bindings, and unconditional bindings with :let:

(when-let [x (rand-nth [:x1 :x2 false nil ]) ; Bind truthy x, or -> nil :let [y (rand-nth [:y1 :y2 false nil x ])] ; Bind any y z (rand-nth [:z1 :z2 false nil x y]) ; Bind truthy z, or -> nil ] [:body x y z])

Supersets `core/when-let` functionality. Like `core/when-let` but supports multiple
bindings, and unconditional bindings with `:let`:

(when-let [x       (rand-nth [:x1 :x2 false nil    ])  ; Bind truthy x, or -> nil
           :let [y (rand-nth [:y1 :y2 false nil x  ])] ; Bind any    y
           z       (rand-nth [:z1 :z2 false nil x y])  ; Bind truthy z, or -> nil
           ]
  [:body x y z])
raw docstring

when-notclj/smacro

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

Supersets core/when-not functionality. Same as encore/if-let with body as else form.

Supersets `core/when-not` functionality.
Same as `encore/if-let` with `body` as `else` form.
raw docstring

when-someclj/smacro

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

Supersets core/when-some functionality. Like core/when-some but supports multiple bindings, and unconditional bindings with :let:

(when-some [x (rand-nth [:x1 :x2 false nil ]) ; Bind non-nil x, or -> else :let [y (rand-nth [:y1 :y2 false nil x ])] ; Bind any y z (rand-nth [:z1 :z2 false nil x y]) ; Bind non-nil z, or -> else ] [:body x y z])

Supersets `core/when-some` functionality. Like `core/when-some` but supports multiple
bindings, and unconditional bindings with `:let`:

(when-some [x       (rand-nth [:x1 :x2 false nil    ])  ; Bind non-nil x, or -> `else`
            :let [y (rand-nth [:y1 :y2 false nil x  ])] ; Bind any     y
            z       (rand-nth [:z1 :z2 false nil x y])  ; Bind non-nil z, or -> `else`
            ]
  [:body x y z])
raw docstring

without-metaclj/s

(without-meta x)

xdistinctclj/s

(xdistinct)
(xdistinct keyfn)

Returns a stateful transducer like (core/distinct) that supports an optional key function. Retains only items with distinct (keyfn <item>).

Returns a stateful transducer like (core/distinct) that supports an optional
key function. Retains only items with distinct (keyfn <item>).
raw docstring

zero-num?clj/s

(zero-num? x)

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

× close