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

taoensso.encore

Extended core library for Clojure/Script that emphasizes:

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

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

Quick Taoensso naming conventions: foo - Dynamic var. foo! - Fn with side effects, or that should otherwise be used cautiously. foo? - Truthy val or fn that returns truthy val. foo!? - Fn that has side effects (or requires caution) and that returns a truthy val. Note: !?, not ?!. foo$ - Fn that's notably expensive to compute (e.g. hits db). foo_ - Dereffable val (e.g. atom, volatile, delay, 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 - 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.

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

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

Quick Taoensso naming conventions:
  **foo** - Dynamic var.
  foo!    - Fn with side effects, or that should otherwise be used cautiously.
  foo?    - Truthy val or fn that returns truthy val.
  foo!?   - Fn that has side effects (or requires caution) and that returns
            a truthy val. Note: !?, not ?!.
  foo$    - Fn that's notably expensive to compute (e.g. hits db).
  foo_    - Dereffable val (e.g. atom, volatile, delay, 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    - 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.
raw docstring

*log-level*cljs

DEPRECATED

DEPRECATED
sourceraw docstring

->?singletonclj/s

(->?singleton coll)
source

->vecclj/s

(->vec x)
source

-as-throwclj/s

(-as-throw as-name x)
source

-assert-unstub-valclj/s≠

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

-condclj/smacro

(-cond throw? & clauses)
source

-core-mergeclj/s

source

-core-update-inclj/s

source

-gc-now?clj/smacro

(-gc-now?)
source

-if-cas!clj/smacro

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

Micro optimization, mostly for cljs.

Micro optimization, mostly for cljs.
sourceraw docstring

-intern-stubclj/smacro

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

-matching-throwableclj/s

(-matching-throwable ex)
(-matching-throwable c ex)
(-matching-throwable c pattern ex)
source

-merge-withclj/s

(-merge-with nest? f maps)
source

-new-stubfn_cljs

(-new-stubfn_ name)
source

-ring-merge-headersclj

(-ring-merge-headers h1 h2)

Experimental.

Experimental.
sourceraw docstring

-swap-cache!clj/s

source

-swap-k!clj/s

source

-swap-val!clj/s

(-swap-val! atom_ k f)

Used internally by memoization utils.

Used internally by memoization utils.
sourceraw docstring

-unswappedclj/s

source

-vol!clj/smacro

(-vol! val)
source

-vol-reset!clj/smacro

(-vol-reset! vol_ val)
source

-vol-swap!clj/smacro

(-vol-swap! vol_ f & args)
source

-vswappedclj/s

source

<*clj/smacro

(<* x y z)
source

<=*clj/smacro

(<=* x y z)
source

>*clj/smacro

(>* x y z)
source

>=*clj/smacro

(>=* x y z)
source

?substr<idxclj/s

source

?substr<lenclj/s

source

?subvec<idxclj/s

source

?subvec<lenclj/s

source

a0-memoize_clj/s

source

a1-memoize_clj/s

source

absclj/s

(abs n)
source

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.
sourceraw docstring

ajax-litecljs

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

Alpha, subject to change. Simple, lightweight Ajax via Google Closure. Returns the resulting XhrIo[1] instance, or nil.

(ajax-lite "/my-post-route" {:method :post :params {:username "Rich Hickey" :type "Awesome"} :headers {"Foo" "Bar"} :resp-type :text :timeout-ms 7000 :with-credentials? false ; Enable if using CORS (requires xhr v2+) } (fn async-callback-fn [resp-map] (let [{:keys [success? ?status ?error ?content ?content-type]} resp-map] ;; ?status - e/o #{nil 200 404 ...}, non-nil iff server responded ;; ?error - e/o #{nil <http-error-status-code> <exception> :timeout :abort :http-error :exception :xhr-pool-depleted} (js/alert (str "Ajax response: " resp-map)))))

[1] Ref. https://developers.google.com/closure/library/docs/xhrio

Alpha, subject to change. Simple, lightweight Ajax via Google Closure.
Returns the resulting XhrIo[1] instance, or nil.

(ajax-lite "/my-post-route"
  {:method     :post
   :params     {:username "Rich Hickey" :type "Awesome"}
   :headers    {"Foo" "Bar"}
   :resp-type  :text
   :timeout-ms 7000
   :with-credentials? false ; Enable if using CORS (requires xhr v2+)
  }
  (fn async-callback-fn [resp-map]
    (let [{:keys [success? ?status ?error ?content ?content-type]} resp-map]
      ;; ?status - e/o #{nil 200 404 ...}, non-nil iff server responded
      ;; ?error  - e/o #{nil <http-error-status-code> <exception> :timeout
                         :abort :http-error :exception :xhr-pool-depleted}
      (js/alert (str "Ajax response: " resp-map)))))

[1] Ref. https://developers.google.com/closure/library/docs/xhrio
sourceraw docstring

approx=clj/s

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

approx==clj/s

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

as-?boolclj/s

(as-?bool x)
source

as-?emailclj/s

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

as-?floatclj/s

(as-?float x)
source

as-?intclj/s

(as-?int x)
source

as-?kwclj/s

(as-?kw x)
source

as-?nameclj/s

(as-?name x)
source

as-?nat-floatclj/s

(as-?nat-float x)
source

as-?nat-intclj/s

(as-?nat-int x)
source

as-?nblankclj/s

(as-?nblank x)
source

as-?nblank-trimclj/s

(as-?nblank-trim x)
source

as-?nemailclj/s

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

as-?nempty-strclj/s

(as-?nempty-str x)
source

as-?nzeroclj/s

(as-?nzero x)
source

as-?pfloatclj/s

source

as-?pintclj/s

source

as-?pnumclj/s

(as-?pnum x)
source

as-?pos-floatclj/s

(as-?pos-float x)
source

as-?pos-intclj/s

(as-?pos-int x)
source

as-?pvalclj/s

source

as-?qnameclj/s

(as-?qname x)
source

as-?rnumclj/s

(as-?rnum x)
source

as-?udtclj/s

(as-?udt x)
source

as-?ufloatclj/s

source

as-?uintclj/s

source

as-boolclj/s

(as-bool x)
source

as-emailclj/s

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

as-floatclj/s

(as-float x)
source

as-intclj/s

(as-int x)
source

as-kwclj/s

(as-kw x)
source

as-mapclj/s

(as-map kvs & [kf vf])

Deprecated, prefer reduce-kvs

Deprecated, prefer `reduce-kvs`
sourceraw docstring

as-nameclj/s

(as-name x)
source

as-nat-floatclj/s

(as-nat-float x)
source

as-nat-intclj/s

(as-nat-int x)
source

as-nblankclj/s

(as-nblank x)
source

as-nblank-trimclj/s

(as-nblank-trim x)
source

as-nemailclj/s

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

as-nempty-strclj/s

(as-nempty-str x)
source

as-nzeroclj/s

(as-nzero x)
source

as-pfloatclj/s

source

as-pintclj/s

source

as-pnumclj/s

(as-pnum x)
source

as-pos-floatclj/s

(as-pos-float x)
source

as-pos-intclj/s

(as-pos-int x)
source

as-pvalclj/s

source

as-qnameclj/s

(as-qname x)
source

as-rnumclj/s

(as-rnum x)
source

as-udtclj/s

(as-udt x)
source

as-ufloatclj/s

source

as-uintclj/s

source

assert-min-encore-versionclj/s

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

Version check for dependency conflicts, etc.

Version check for dependency conflicts, etc.
sourceraw docstring

assoc-nxclj/s

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

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

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

assoc-someclj/s

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

Assocs each kv iff its value is not nil.

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

assoc-whenclj/s

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

Assocs each kv iff its val is truthy.

Assocs each kv iff its val is truthy.
sourceraw docstring

atom?clj/s

(atom? x)
source (clj)source (cljs)

ba-concatclj

(ba-concat ba1 ba2)
source

ba-splitclj

(ba-split ba idx)
source

ba=clj

(ba= x y)
source

backport-run!clj/s

source

benchclj/smacro

(bench nlaps opts & body)
source

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.
sourceraw docstring

boolean?clj/s

(boolean? x)
source (clj)source (cljs)

bytes-classclj

source

bytes?clj

(bytes? x)
source

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.
sourceraw docstring

case-evalclj/smacro

(case-eval expr & clauses)

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

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

catch-errorsclj/smacro

(catch-errors & body)
source

catch-errors*clj/smacro

(catch-errors* & args)
source

catchingclj/smacro

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

Cross-platform try/catch/finally.

Cross-platform try/catch/finally.
sourceraw docstring

caught-error-dataclj/smacro

(caught-error-data & body)

Handy for error-throwing unit tests.

Handy for error-throwing unit tests.
sourceraw docstring

chan?clj/s

(chan? x)
source (clj)source (cljs)

chanceclj/s

(chance p)
source

check-allclj/smacro

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

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

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

check-someclj/smacro

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

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

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

clampclj/s

(clamp nmin nmax n)
source

clamp*clj/smacro

(clamp* nmin nmax n)
source

clj1098clj/s

(clj1098 x)
Ref. http://goo.gl/0GzRuz
sourceraw 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`.
sourceraw docstring

compile-ns-filterclj/s

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

Deprecated, prefer compile-str-filter instead.

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

compile-str-filterclj/s

(compile-str-filter spec)

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

Spec may be:

  • A regex pattern. Will conform on match.

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

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

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

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

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

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

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

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

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

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

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

compile-whenclj/smacro

(compile-when test & body)
source

compiling-cljs?clj

(compiling-cljs?)

Return truthy iff currently generating Cljs code.

Return truthy iff currently generating Cljs code.
sourceraw docstring

condclj/smacro

(cond & clauses)

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

(cond :let [x "x"] ; Establish bindings visible to following forms

:do (println (str "x value: " x)) ; Eval expr for side effects

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

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

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

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

(cond
  :let [x "x"] ; Establish bindings visible to following forms

  :do (println (str "x value: " x)) ; Eval expr for side effects

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

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

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

cond*clj/smacro

(cond* & args)
source

cond-throwclj/smacro

(cond-throw & args)
source

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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

contains-in?clj/s

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

convey-reducedclj/s

(convey-reduced x)
source

count-wordsclj/s

(count-words s)
source

Countercljs

source

counterclj/s

(counter)
(counter init)

Returns a fast atomic Counter with init initial int value:

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

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

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

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

debugfcljs

(debugf fmt & xs)
source

declare-remoteclj/smacro

(declare-remote & syms)

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

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

defaliasclj/smacro

(defalias src)
(defalias sym src)
(defalias sym src attrs)

Defines an alias for qualified source symbol, preserving its metadata (clj only): (defalias my-map-alias clojure.core/map)

Cannot alias Cljs macros. Changes to source are not automatically applied to alias.

Defines an alias for qualified source symbol, preserving its metadata (clj only):
  (defalias my-map-alias clojure.core/map)

Cannot alias Cljs macros.
Changes to source are not automatically applied to alias.
sourceraw 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).
sourceraw docstring

DefaultTimeoutImplcljs

source

defonceclj/smacro

(defonce sym & args)

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

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

defonce*clj/smacro

(defonce* & args)
source

defstubclj/smacro

(defstub sym)

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

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

deprecatedclj/smacro

(deprecated & body)

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

Elides body when `taoensso.elide-deprecated` JVM property or
`TAOENSSO_ELIDE_DEPRECATED` environment variable is e/o #{"true" "TRUE"}.
sourceraw docstring

derefable?clj/s

(derefable? x)
source (clj)source (cljs)

dis-assoc-someclj/s

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

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

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

dissoc-inclj/s

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

distinct-byclj/s

(distinct-by keyfn coll)

Deprecated, prefer xdistinct

Deprecated, prefer `xdistinct`
sourceraw docstring

distinct-elements?clj/s

(distinct-elements? x)
source

distinctvclj/s

(distinctv coll)
(distinctv keyfn coll)

Deprecated, prefer xdistinct

Deprecated, prefer `xdistinct`
sourceraw docstring

do-falseclj/smacro

(do-false & body)
source

do-nilclj/smacro

(do-nil & body)
source

do-trueclj/smacro

(do-true & body)
source

doto-condclj/smacro

(doto-cond [sym x] & clauses)

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

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

dswap!clj/s

source

editable?clj/s

(editable? x)
source (clj)source (cljs)

encore-versionclj/s

source

ensure-setclj/s

(ensure-set x)
source

ensure-vecclj/s

(ensure-vec x)
source

error-dataclj/s

(error-data x)

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

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

error?clj/s

(error? x)
source (clj)source (cljs)

errorfcljs

(errorf fmt & xs)
source

everyclj/s

source

exception?clj

(exception? x)
source

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.
sourceraw docstring

explode-keywordclj/s

(explode-keyword k)
source

fatalfcljs

(fatalf fmt & xs)
source

file-resources-modified?clj

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

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

filter-keysclj/s

(filter-keys pred m)
source

filter-kvsclj/s

(filter-kvs pred m)
source

filter-valsclj/s

(filter-vals pred m)
source

float?clj/s

(float? x)
source (clj)source (cljs)

fmemoizeclj/s

(fmemoize f)

Fastest-possible Clj memoize. Non-racy, 0-3 arity only. Cljs just passes through to core/memoize.

Fastest-possible Clj memoize. Non-racy, 0-3 arity only.
Cljs just passes through to `core/memoize`.
sourceraw docstring

force-refclj/s

(force-ref x)

Like force for refs.

Like `force` for refs.
sourceraw 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`!).
sourceraw docstring

format*clj/s

(format* fmt args)
source

format-query-stringclj/s

(format-query-string m)
source

fq-nameclj/s

source

future-poolclj

(future-pool n)

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

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

fzipmapclj/s

(fzipmap ks vs)
source

get-dynamic-assertion-dataclj

(get-dynamic-assertion-data)

Returns current value of dynamic assertion data.

Returns current value of dynamic assertion data.
sourceraw docstring

get-envclj/smacro

(get-env)
source

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.
sourceraw docstring

get-hostnameclj

(get-hostname)

Returns local hostname string, or nil.

Returns local hostname string, or nil.
sourceraw 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.
sourceraw docstring

get-substrclj/s

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

Like subs but provides consistent clj/s behaviour and never throws (snaps to valid start and end indexes).

Like `subs` but provides consistent clj/s behaviour and never throws
(snaps to valid start and end indexes).
sourceraw docstring

get-substringclj/s

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

Like get-substr but:

  • Takes length instead of end (index).
  • -ive start => index from right of string.
Like `get-substr` but:
- Takes `length` instead of `end` (index).
- -ive `start` => index from right of string.
sourceraw docstring

get-subvecclj/s

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

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

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

get-subvectorclj/s

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

Like get-subvec but:

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

get-sys-boolclj

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

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

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

Returns default if neither property nor environment variable is set.

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

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

get-sys-valclj

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

get-win-loccljs

(get-win-loc)

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

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

get-window-locationcljs

source

greatestclj/s

(greatest coll & [?comparator])
source

haveclj/s≠macro

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

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

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

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

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

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

See also have?, have!.

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

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

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

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

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

See also `have?`, `have!`.
cljs
(have & args)
source (clj)source (cljs)raw docstring

have!clj/smacro

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

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

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

have!?clj/smacro

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

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

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

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

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

have-core-async?clj

source

have-inclj/smacro

(have-in a1 & an)
source

have-in!clj/smacro

(have-in! a1 & an)
source

have-transducers?clj/s

source

have?clj/s≠macro

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

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

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

ident?clj/s

(ident? x)
source (clj)source (cljs)

idx-fnclj/s

source

if-cljclj/smacro

(if-clj then & [else])
source

if-cljsclj/smacro

(if-cljs then & [else])
source

if-letclj/smacro

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

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

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

if-letsclj/smacro

(if-lets & args)
source

if-notclj/smacro

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

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

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

if-not*clj/smacro

(if-not* & args)
source

if-someclj/smacro

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

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

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

indexed?clj/s

(indexed? x)
source (clj)source (cljs)

infofcljs

(infof fmt & xs)
source

int?clj/s

(int? x)
source (clj)source (cljs)

interleave-allclj/s

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

Greedy version of interleave.

Greedy version of `interleave`.
sourceraw docstring

into!clj/s

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

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.
sourceraw docstring

into-strclj/s

(into-str & xs)

Simple Hiccup-like string templating to complement Tempura.

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

invert-mapclj/s

(invert-map m)
source

is!clj/s

(is! x)
(is! pred x)
(is! pred x fail-?data)

Cheaper have! that provides less diagnostic info.

Cheaper `have!` that provides less diagnostic info.
sourceraw 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.
source

ITimeoutImplclj/sprotocol

-schedule-timeoutclj/s

(-schedule-timeout _ msecs f)
source

join-onceclj/s

(join-once sep & coll)
source

js-?wincljs

source

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`.
sourceraw docstring

keys<=clj/s

(keys<= m ks)
source

keys=clj/s

(keys= m ks)
source

keys=nnil?clj/s

(keys=nnil? m ks)
source

keys>=clj/s

(keys>= m ks)
source

keywordize-mapclj/s

(keywordize-map m)
source

ks-nnil?clj/s

(ks-nnil? ks m)
source

ks<=clj/s

(ks<= ks m)
source

ks=clj/s

(ks= ks m)
source

ks>=clj/s

(ks>= ks m)
source

kw-identical?clj/s≠

clj
(kw-identical? x y)

Tests if 2 arguments are the same object

Tests if 2 arguments are the same object
cljs
source (clj)source (cljs)raw docstring

lazy-seq?clj/s

(lazy-seq? x)
source (clj)source (cljs)

leastclj/s

(least coll & [?comparator])
source

LimitEntrycljs

source

limiterclj/s

(limiter specs)

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

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

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

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

limiter*clj/s

(limiter* specs)

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

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

LimitHitscljs

source

LimitSpeccljs

source

logcljs

source

logfcljs

(logf fmt & xs)
source

logging-levelclj/s

source

logpcljs

(logp & xs)
source

map-keysclj/s

(map-keys f m)
source

map-kvsclj/s

(map-kvs kf vf m)

Deprecated, prefer reduce-kv

Deprecated, prefer `reduce-kv`
sourceraw docstring

map-valsclj/s

(map-vals f m)
source

mapplyclj/s

(mapply f & args)

Like apply but calls seq-kvs on final arg.

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

max*clj/smacro

(max* n1 n2)
source

max-longclj/s

source

memoizeclj/s

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

Like core/memoize but:

  • Often faster, depending on opts.
  • Prevents race conditions on writes.
  • Supports auto invalidation & gc with ttl-ms opt.
  • Supports cache size limit & gc with cache-size opt.
  • Supports invalidation by prepending args with :mem/del or :mem/fresh.
Like `core/memoize` but:
* Often faster, depending on opts.
* Prevents race conditions on writes.
* Supports auto invalidation & gc with `ttl-ms` opt.
* Supports cache size limit & gc with `cache-size` opt.
* Supports invalidation by prepending args with `:mem/del` or `:mem/fresh`.
sourceraw docstring

memoize*clj/s

source

memoize-1clj/s

source

memoize-a0_clj/s

source

memoize-a1_clj/s

source

memoize-lastclj/s

(memoize-last f)

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

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

memoize1clj/s

source

memoize_clj/s

(memoize_ f)

Like core/memoize but faster, non-racy, and supports invalidation.

Like `core/memoize` but faster, non-racy, and supports invalidation.
sourceraw docstring

memoizedclj/s

(memoized cache f & args)
source

mergeclj/s

(merge & maps)

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

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

merge-deepclj/s

source

merge-deep-withclj/s

source

merge-headersclj

(merge-headers rresp headers)
source

merge-keywordsclj/s

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

merge-metaclj/s

(merge-meta x m)
source

merge-url-with-query-stringclj/s

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

merge-withclj/s

(merge-with f & maps)

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

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

min*clj/smacro

(min* n1 n2)
source

min-longclj/s

source

msclj/s

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

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

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

ms->secsclj/s

(ms->secs ms)
source

msecsclj/smacro

(msecs & opts)

Compile-time version of ms

Compile-time version of `ms`
sourceraw 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>] with support for defn style ?docstring and ?attrs-map.

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

named?clj/s

(named? x)
source (clj)source (cljs)

nano-timeclj/s

source

nano-time*clj/smacro

(nano-time* & args)
source

nanoidclj/s

(nanoid)
(nanoid len)

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

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

nanoid-alphabetclj/s

source

nat-float?clj/s

(nat-float? x)
source (clj)source (cljs)

nat-int?clj/s

(nat-int? x)
source (clj)source (cljs)

nat-num?clj/s

(nat-num? x)
source (clj)source (cljs)

nblank-str?clj/s

(nblank-str? x)
source (clj)source (cljs)

nblank?clj/s

(nblank? x)
source (clj)source (cljs)

neg-float?clj/s

(neg-float? x)
source (clj)source (cljs)

neg-int?clj/s

(neg-int? x)
source (clj)source (cljs)

neg-num?clj/s

(neg-num? x)
source (clj)source (cljs)

nempty-str?clj/s

(nempty-str? x)
source (clj)source (cljs)

nested-mergeclj/s

(nested-merge & maps)

Like merge but does nested merging.

Like `merge` but does nested merging.
sourceraw docstring

nested-merge-withclj/s

(nested-merge-with f & maps)

Like merge-with but does nested merging.

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

new-objectclj/smacro

(new-object)
source

nil->sentinelclj/s

(nil->sentinel x)
source

nil->strclj/s

(nil->str x)

nil/undefined -> "nil"

nil/undefined -> "nil"
sourceraw docstring

nneg-float?clj/s

source

nneg-int?clj/s

source

nneg-num?clj/s

source

nneg?clj/s

(nneg? x)
source (clj)source (cljs)

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.
sourceraw docstring

nnil-setclj/s

(nnil-set x)
source

nnil=clj/s

source

nnil?clj/s

source

node-pathsclj/s

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

node-target?cljs

source

norm-strclj

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

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

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

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

`form` is e/o #{:nfc :nfkc :nfd :nfkd <java.text.NormalizerForm>}.
Defaults to :nfc as per W3C recommendation.
sourceraw 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.
sourceraw docstring

normalize-headersclj

(normalize-headers rreq-or-rresp)
source

now-dtclj/s

(now-dt)
source

now-dt*clj/smacro

(now-dt*)
source

now-nanoclj/s≠

clj
(now-nano)
cljs

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

Uses window context as epoch, Ref. http://goo.gl/mWZWnR
source (clj)source (cljs)raw docstring

now-nano*clj/smacro

(now-nano*)
source

now-udtclj/s

(now-udt)
source

now-udt*clj/smacro

(now-udt*)
source

nvec?clj/s

(nvec? n x)
source

ogetcljs

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

Like get for JS objects.

Like `get` for JS objects.
sourceraw 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.
sourceraw docstring

osetcljs

(oset o k v)

Like assoc for JS objects.

Like `assoc` for JS objects.
sourceraw docstring

oset-incljs

(oset-in o ks v)

Experimental. Like assoc-in for JS objects.

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

parse-boolclj/s

source

parse-floatclj/s

source

parse-intclj/s

source

parse-query-paramsclj/s

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

Based on ring-codec/form-decode.

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

parse-versionclj/s

(parse-version x)
source

pathclj/s

(path & parts)
source

percclj/s

(perc n divisor)
source

pint?clj/s

source

pnum?clj/s

(pnum? x)
source (clj)source (cljs)

pos-float?clj/s

(pos-float? x)
source (clj)source (cljs)

pos-int?clj/s

(pos-int? x)
source (clj)source (cljs)

pos-num?clj/s

(pos-num? x)
source (clj)source (cljs)

powclj/s

(pow n exp)
source

pr-ednclj/s

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

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

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

preserve-reducedclj/s

(preserve-reduced rf)

As core/preserving-reduced.

As `core/preserving-reduced`.
sourceraw docstring

pull-val!clj/s

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

Removes and returns value mapped to key.

Removes and returns value mapped to key.
sourceraw docstring

pval?clj/s

source

qbclj/smacro

(qb & args)
source

qbenchclj/smacro

(qbench & args)
source

qnameclj/s

source

qualified-ident?clj/s

(qualified-ident? x)
source (clj)source (cljs)

qualified-keyword?clj/s

(qualified-keyword? x)
source (clj)source (cljs)

qualified-symbol?clj/s

(qualified-symbol? x)
source (clj)source (cljs)

queueclj/s

(queue)
(queue coll)

Returns a PersistentQueue.

Returns a PersistentQueue.
sourceraw docstring

queue*clj/s

(queue* & items)
source

queue?clj/s

(queue? x)
source (clj)source (cljs)

quick-benchclj/smacro

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

Returns fastest of 3 sets of times for each form, in msecs.

Returns fastest of 3 sets of times for each form, in msecs.
sourceraw docstring

rate-limitclj/s

(rate-limit specs f)
source

rate-limitedclj/s

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

rate-limiterclj/s

(rate-limiter ncalls-limit window-ms)
source

rate-limiter*clj/s

(rate-limiter* specs)

Deprecated, prefer limiter

Deprecated, prefer `limiter`
sourceraw docstring

rcompareclj/s

(rcompare x y)

Reverse comparator.

Reverse comparator.
source (clj)source (cljs)raw docstring

re-pattern?clj/s

(re-pattern? x)
source (clj)source (cljs)

read-ednclj/s

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

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

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

read-sys-valclj

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

redirect-respclj

source

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.
sourceraw 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.
sourceraw docstring

reduce-nclj/s

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

reduce-objcljs

(reduce-obj f init o)

Like reduce-kv but for JavaScript objects.

Like `reduce-kv` but for JavaScript objects.
sourceraw 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 ...)).
sourceraw docstring

regular-num?cljs

(regular-num? x)
source

remove-keysclj/s

(remove-keys pred m)
source

remove-kvsclj/s

(remove-kvs pred m)
source

remove-valsclj/s

(remove-vals pred m)
source

removevclj/s

(removev pred coll)
source

rename-keysclj/s

(rename-keys replacements m)

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

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

repeatedly*clj/smacro

(repeatedly* n & body)
source

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.
sourceraw docstring

repeatedly-into*clj/smacro

(repeatedly-into* coll n & body)

Deprecated

Deprecated
sourceraw docstring

replace-inclj/s

(replace-in m & ops)
source

reportfcljs

(reportf fmt & xs)
source

reset!?clj/s

(reset!? atom_ val)

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

Atomically swaps value of `atom_` to `val` and returns
true iff the atom's value actually changed. See also `reset-in!?`.
sourceraw 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>.
sourceraw docstring

reset-val!clj/s

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

Low-level util, returns <old-key-val>.

Low-level util, returns <old-key-val>.
sourceraw docstring

reset-val!?clj/s

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

Maps value to key and returns true iff the mapped value changed or was created.

Maps value to key and returns true iff the mapped value changed or
was created.
sourceraw docstring

reveryclj/s

(revery pred coll)
source

revery-kvclj/s

(revery-kv pred coll)
source

revery-kv?clj/s

(revery-kv? pred coll)
source

revery?clj/s

(revery? pred coll)
source

rfirstclj/s

(rfirst pred coll)
source

rfirst-kvclj/s

(rfirst-kv pred coll)
source

ring-default-headersclj

(ring-default-headers headers rresp)
source

ring-merge-headersclj

(ring-merge-headers headers rresp)
source

ring-redirect-respclj

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

ring-resp-mapclj

(ring-resp-map x)
source

ring-set-bodyclj

(ring-set-body body rresp)
source

ring-set-headersclj

(ring-set-headers headers rresp)
source

ring-set-statusclj

(ring-set-status code rresp)
source

rnum?clj/s

(rnum? x)
source (clj)source (cljs)

rolling-counterclj/s

(rolling-counter msecs)

Experimental. Returns a RollingCounter that you can:

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

RollingCountercljs

source

roundclj/s

(round n & [type nplaces])
source

round*clj/s

(round* n)
(round* type n)
(round* type nplaces n)
source

round0clj/s

(round0 n)
source

round1clj/s

(round1 n)
source

round2clj/s

(round2 n)
source

rsomeclj/s

(rsome pred coll)
source

rsome-kvclj/s

(rsome-kv pred coll)
source

run!clj/s

(run! proc coll)
source

run!*clj/s

source

run-kv!clj/s

(run-kv! proc m)
source

run-kvs!clj/s

(run-kvs! proc kvs)
source

run-obj!cljs

(run-obj! proc obj)
source

sayfcljs

(sayf fmt & xs)
source

saypcljs

(sayp & xs)
source

sb-appendclj/s

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

For cross-platform string building

For cross-platform string building
sourceraw docstring

secsclj/s

source

secs->msclj/s

(secs->ms secs)
source

secure-rand-bytesclj/s

(secure-rand-bytes size)

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

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

secure-rand-idclj/s

(secure-rand-id alphabet len)

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

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

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

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

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

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

secure-rngclj

(secure-rng)

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

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

sentinelclj/s

source

sentinel->nilclj/s

(sentinel->nil x)
source

sentinel?clj/s

(sentinel? x)
source

seq-kvsclj/s

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

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

session-swapclj

(session-swap rreq rresp f & args)

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

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

set*clj/s

source

set-bodyclj

(set-body rresp body)
source

set-exp-backoff-timeout!cljs

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

set-statusclj

(set-status rresp code)
source

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`.
sourceraw docstring

simple-date-format*clj

(simple-date-format* pattern locale timezone)
source

simple-ident?clj/s

(simple-ident? x)
source (clj)source (cljs)

simple-keyword?clj/s

(simple-keyword? x)
source (clj)source (cljs)

simple-symbol?clj/s

(simple-symbol? x)
source (clj)source (cljs)

SimpleCacheEntrycljs

source

singleton?clj/s

(singleton? coll)
source

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.
sourceraw 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.
sourceraw docstring

some=clj/s

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

some?clj/s

(some? x)
source (clj)source (cljs)

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`.
sourceraw docstring

spaced-strclj/s

(spaced-str xs)
source

spaced-str-with-nilsclj/s

(spaced-str-with-nils xs)
source

srngclj

source

str-?indexclj/s

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

str-builderclj/s

For cross-platform string building

For cross-platform string building
sourceraw docstring

str-builder?clj/s

(str-builder? x)
source (clj)source (cljs)

str-contains?clj/s

(str-contains? s substr)
source

str-ends-with?clj/s

(str-ends-with? s substr)
source

str-joinclj/s

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

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

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

str-join-onceclj/s

(str-join-once separator coll)

Like string/join but skips duplicate separators.

Like `string/join` but skips duplicate separators.
sourceraw 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.
sourceraw docstring

str-rfclj/s

String builder reducing fn

String builder reducing fn
sourceraw docstring

str-starts-with?clj/s

(str-starts-with? s substr)
source

stringy?clj/s

(stringy? x)
source (clj)source (cljs)

sub-indexesclj/s

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

substrclj/s

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

Deprecated, prefer get-substr or get-substring

Deprecated, prefer `get-substr` or `get-substring`
sourceraw docstring

subvec*clj/s

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

Deprecated, prefer get-subvec or get-subvector

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

swap!*clj/s

source

swap-in!clj/s

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

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

Like `swap!` but supports `update-in` semantics,
returns <new-key-val> or <swapped-return-val>.
sourceraw 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, returns [<old-key-val> <new-key-val>].

Like `swap!` but supports `update-in` semantics,
returns [<old-key-val> <new-key-val>].
sourceraw docstring

swap-val!clj/s

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

Low-level util, returns <new-key-val> or <swapped-return-val>.

Low-level util, returns <new-key-val> or <swapped-return-val>.
sourceraw docstring

swap-val!*clj/s

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

Low-level util, returns [<old-key-val> <new-key-val>].

Low-level util, returns [<old-key-val> <new-key-val>].
sourceraw docstring

swappedclj/s

(swapped new-val return-val)
source

Swappedcljs

source

swapped*clj/s

source

swapped-vecclj/s

(swapped-vec x)
source

swapped?clj/s

(swapped? x)
source (clj)source (cljs)

system-newlineclj/s

source (clj)source (cljs)

takevclj/s

(takev n coll)
source

thread-local-proxyclj/smacro

(thread-local-proxy & body)
source

throwable?clj

(throwable? x)
source

thrownclj/smacro

(thrown form)
(thrown c form)
(thrown c pattern form)

Evaluates form and returns ?throwable thrown by form that matches given criteria:

  • c may be:

    • A class (e.g. ArithmeticException, AssertionError, etc.)
    • :default => default platform throwable (Exception or js/Error)
    • :any => any platform throwable (Throwable or js/Error)
  • pattern may be

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

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

Evaluates `form` and returns ?throwable thrown by form that matches
given criteria:

  - `c` may be:
    - A class (e.g. ArithmeticException, AssertionError, etc.)
    - `:default` => default platform throwable (Exception or js/Error)
    - `:any`     => any     platform throwable (Throwable or js/Error)

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

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

TickedCacheEntrycljs

source

time-msclj/smacro

(time-ms & body)

Returns number of milliseconds it took to execute body.

Returns number of milliseconds it took to execute body.
sourceraw 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.
sourceraw docstring

timeout-future?clj/s

(timeout-future? x)
source (clj)source (cljs)

TimeoutFuturecljs

source

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`.
sourceraw 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`.
sourceraw docstring

tracefcljs

(tracef fmt & xs)
source

transient?clj/s

(transient? x)
source (clj)source (cljs)

udt?clj/s

(udt? x)
source (clj)source (cljs)

uint?clj/s

source

undefined->nilcljs

(undefined->nil x)
source

update-inclj/s

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

Like core/update-in but:.

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

update-in*clj/s

source

uri?clj

(uri? x)
source

url-decodeclj/s

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

url-encodeclj/s≠

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

use-fixtures*clj/smacro

(use-fixtures* & args)
source

uuid-strclj/s

(uuid-str)
(uuid-str max-length)

Returns a UUIDv4 string of form "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx". Ref. http://www.ietf.org/rfc/rfc4122.txt, https://gist.github.com/franks42/4159427

Returns a UUIDv4 string of form "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".
Ref. http://www.ietf.org/rfc/rfc4122.txt,
     https://gist.github.com/franks42/4159427
sourceraw docstring

vec*clj/s

source

vec2?clj/s

(vec2? x)
source (clj)source (cljs)

vec3?clj/s

(vec3? x)
source (clj)source (cljs)

vinterleave-allclj/s

(vinterleave-all c1 c2)
source

vnextclj/s

(vnext v)
source

vrestclj/s

(vrest v)
source

vsplit-firstclj/s

(vsplit-first v)
source

vsplit-lastclj/s

(vsplit-last v)
source

warnfcljs

(warnf fmt & xs)
source

whenclj/smacro

(when test-or-bindings & body)

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

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

when-letclj/smacro

(when-let bindings & body)

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

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

when-letsclj/smacro

(when-lets & args)
source

when-notclj/smacro

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

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

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

when-someclj/smacro

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

when?clj/s

(when? pred x)
source

with-dynamic-assertion-dataclj/smacro

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

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

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

without-metaclj/s

(without-meta x)
source

xdistinctclj/s

(xdistinct)
(xdistinct keyfn)
source

zero-num?clj/s

(zero-num? x)
source (clj)source (cljs)

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

× close