Liking cljdoc? Tell your friends :D

trident.util

Utility library. Docstrings are omitted for simple functions; read the source to see what they do.

Utility library. Docstrings are omitted for simple functions; read the source
to see what they do.
raw docstring

add-secondsclj/s

(add-seconds date seconds)
source

assoc-not-emptyclj/s

(assoc-not-empty m & kvs)
source

assoc-predclj/s

(assoc-pred m f & kvs)

Like assoc, but skip kv pairs where (f v) is false.

Like assoc, but skip kv pairs where (f v) is false.
sourceraw docstring

assoc-someclj/s

(assoc-some m & kvs)
source

avgclj/s

(avg xs)
source

captureclj/smacro

(capture & xs)
source

capture-envclj/smacro

(capture-env nspace)
source

capture-env*clj/s

(capture-env* nspace)
source

catchallclj/smacro

(catchall & forms)
source

catchall-jsclj/smacro

(catchall-js & forms)
source

ceil-atclj/s

(ceil-at x n)
source

chan?cljs

(chan? x)
source

char->intcljs

source

cljs-import-varsclj/smacro

(cljs-import-vars nspace & syms)

Like potemkin/import-vars but supports importing cljs-only functions.

Example:

(cljs-import-vars my.namespace.core
                  foo bar baz)
Like `potemkin/import-vars` but supports importing cljs-only functions.

Example:
```
(cljs-import-vars my.namespace.core
                  foo bar baz)
```
sourceraw docstring

compare<clj/s

(compare< x y)
source

compare<=clj/s

(compare<= x y)
source

compare=clj/s

(compare= x y)
source

compare>clj/s

(compare> x y)
source

compare>=clj/s

(compare>= x y)
source

condas->clj/smacro

(condas-> expr name & clauses)

Combination of cond-> and as->.

Combination of `cond->` and `as->`.
sourceraw docstring

defcursorsclj/smacro

(defcursors db & forms)
source

defderivationsclj/smacro

(defderivations & args)
source

derivationsclj

(derivations sources nspace & forms)
source

derive-configclj/s

(derive-config m)

Replaces any ^:derived values in m.

Example:

(def m
  {:first-name "John"
   :last-name  "Doe"
   :full-name ^:derived #(str (get-config % :first-name) " "
                              (get-config % :last-name))})

(derive-config m)
=> {:first-name "John" :last-name  "Doe" :full-name "John Doe"}

Any values with a truthy :derived metadata value must be single-argument functions. These functions will be replaced with their return values, with the config map as the argument.

get-config is like get, but if the return value is a :derived function, get-config will derive it before returning. It should be used within :derived function as in the example

Replaces any `^:derived` values in `m`.

Example:
```
(def m
  {:first-name "John"
   :last-name  "Doe"
   :full-name ^:derived #(str (get-config % :first-name) " "
                              (get-config % :last-name))})

(derive-config m)
=> {:first-name "John" :last-name  "Doe" :full-name "John Doe"}
```
Any values with a truthy `:derived` metadata value must be single-argument
functions. These functions will be replaced with their return values, with
the config map as the argument.

`get-config` is like `get`, but if the return value is a `:derived` function,
`get-config` will derive it before returning. It should be used within
`:derived` function as in the example 
sourceraw docstring

dissoc-emptyclj/s

(dissoc-empty m)
source

dissoc-vecclj/s

(dissoc-vec v i)
source

distinct-byclj/s

(distinct-by f xs)
source

doclinesclj/s

(doclines _var)

Returns the docstring of a var as a collection of lines, removing indentation.

Returns the docstring of a var as a collection of lines, removing indentation.
sourceraw docstring

emptyish?clj/s

(emptyish? x)
source

flatten-formclj

(flatten-form form)
source

for-every?clj/smacro

(for-every? & forms)
source

for-some?clj/smacro

(for-some? & forms)
source

forcatclj/smacro

(forcat & forms)
source

formatcljs

alias for goog.string.format

alias for `goog.string.format`
sourceraw docstring

format-columnsclj/s

(format-columns rows)

Formats rows of text into columns.

Example:

(doseq [row (format-columns [["hellooooooooo " "there"]
                             ["foo " "bar"]
                             ["one column"]])]
  (println row))
hellooooooooo there
foo           bar
one column
Formats rows of text into columns.

Example:
```
(doseq [row (format-columns [["hellooooooooo " "there"]
                             ["foo " "bar"]
                             ["one column"]])]
  (println row))
hellooooooooo there
foo           bar
one column
```
sourceraw docstring

format-dateclj

(format-date date out-format)
source

forvclj/smacro

(forv & body)
source

get-configclj/s

(get-config m k)
(get-config m k not-found)

See [derive-config].

See [derive-config].
sourceraw docstring

get-in-configclj/s

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

See [derive-config].

See [derive-config].
sourceraw docstring

go-compcljs

(go-comp & fs)
source

if-some-allclj/smacro

(if-some-all [& bindings] & [then else :as forms])
source (clj)source (cljs)

inheritclj/smacro

(inherit child-name [parent-instance :as fields] & overrides)

Like deftype but with default function implementations.

The first field is the "parent": for any protocol functions you don't define, the function will be called again with the parent as the first argument instead of the current object.

Example:

(defprotocol P
  (foo [this])
  (bar [this]))

(deftype Parent []
  P
  (foo [_] "parent foo")
  (bar [_] "parent bar"))

(inherit Child [parent]
  P
  (foo [_] "child foo"))

(def parent (Parent.))
(def child (Child. parent))

(foo child)
=> "child foo"
(bar child)
=> "parent bar"
Like `deftype` but with default function implementations.

The first field is the "parent": for any protocol functions you don't define,
the function will be called again with the parent as the first argument instead
of the current object.

Example:
```
(defprotocol P
  (foo [this])
  (bar [this]))

(deftype Parent []
  P
  (foo [_] "parent foo")
  (bar [_] "parent bar"))

(inherit Child [parent]
  P
  (foo [_] "child foo"))

(def parent (Parent.))
(def child (Child. parent))

(foo child)
=> "child foo"
(bar child)
=> "parent bar"
```
sourceraw docstring

instant?clj/s

(instant? x)
source

interleave-weightedclj/s

(interleave-weighted w coll-a coll-b)
source

js<!clj/smacro

(js<! form)

Like <! but for js promises. See to-chan.

Like `<!` but for js promises. See [[to-chan]].
sourceraw docstring

load-fnsclj/smacro

(load-fns & forms)

Defines a bunch of "dynamic functions" (see loadf).

Example:

(load-fns
  foo my.lib/foo
  bar my.lib/bar
  baz your.lib/baz)
(foo) ; same as (do (require 'my.lib) (my.lib/foo))
Defines a bunch of "dynamic functions" (see [[loadf]]).

Example:
```
(load-fns
  foo my.lib/foo
  bar my.lib/bar
  baz your.lib/baz)
(foo) ; same as (do (require 'my.lib) (my.lib/foo))
```
sourceraw docstring

load-varclj

(load-var sym)

Dynamically loads a var.

sym: a fully-qualified var symbol.

Dynamically loads a var.

`sym`: a fully-qualified var symbol.
sourceraw docstring

loadfclj

(loadf sym)

Returns a function that dynamically loads and calls the specified function.

sym: a fully-qualified function symbol.

Returns a function that dynamically loads and calls the specified function.

`sym`: a fully-qualified function symbol.
sourceraw docstring

maintain-subscriptionscljs

(maintain-subscriptions sub-atom sub-fn)

Watch for changes in a set of subscriptions (stored in sub-atom), subscribing and unsubscribing accordingly. sub-fn should take an element of @sub-atom and return a channel that delivers the subscription channel after the first subscription result has been received. This is necessary because otherwise, old subscriptions would be closed too early, causing problems for the calculation of sub-atom.

Watch for changes in a set of subscriptions (stored in sub-atom), subscribing
and unsubscribing accordingly. sub-fn should take an element of @sub-atom and
return a channel that delivers the subscription channel after the first subscription result
has been received. This is necessary because otherwise, old subscriptions would
be closed too early, causing problems for the calculation of sub-atom.
sourceraw docstring

map-fromclj/s

(map-from f xs)
source

map-from-toclj/s

(map-from-to f g xs)
source

map-keysclj/s

(map-keys f m)
source

map-kvclj/s

(map-kv f m)
source

map-toclj/s

(map-to f xs)
source

map-valsclj/s

(map-vals f m)
source

maybe-slurpclj

(maybe-slurp f)

Attempts to slurp f, returning nil on failure

Attempts to slurp `f`, returning nil on failure
sourceraw docstring

merge-subscription-results!cljs

(merge-subscription-results! {:keys [sub-data-atom merge-result sub-key
                                     sub-channel]})

Continually merge results from subscription into sub-data-atom. Returns a channel that delivers sub-channel after the first result has been merged.

Continually merge results from subscription into sub-data-atom. Returns a channel
that delivers sub-channel after the first result has been merged.
sourceraw docstring

nowclj/s

(now)
source

padclj/s

(pad n _val coll)
source

parse-dateclj

(parse-date date in-format)
source

parse-format-dateclj

(parse-format-date date in-format out-format)
source

parse-intclj/s

(parse-int s)
source (clj)source (cljs)

parse-urlclj/s

(parse-url url)
source

pprintclj/s

source

pred->clj/s

(pred-> x f g)
source

prepend-keysclj/s

(prepend-keys ns-segment m)
source

prepend-nsclj/s

(prepend-ns ns-segment k)
source

(print-table header-info table)

Prints a nicely formatted table.

Example:

(print-table
  [[:foo "Foo"] [:bar "Bar"]]
  [{:foo 1 :bar 2} {:foo 3 :bar 4}])
=> Foo  Bar
   1    2
   3    4
Prints a nicely formatted table.

Example:
```
(print-table
  [[:foo "Foo"] [:bar "Bar"]]
  [{:foo 1 :bar 2} {:foo 3 :bar 4}])
=> Foo  Bar
   1    2
   3    4
```
sourceraw docstring

rand-strclj/s

(rand-str len)
source

random-byclj/s

(random-by f xs)
source

read-configclj

(read-config filename)
source

respectivelyclj/s

(respectively & fs)
source

roundclj/s

(round t)
(round t places)
source

sample-byclj/s

(sample-by f xs)
source

shclj

(sh & args)

Runs a shell command.

Returns the output if successful; otherwise, throws an exception.

Runs a shell command.

Returns the output if successful; otherwise, throws an exception.
sourceraw docstring

split-byclj/s

(split-by pred xs)
source

spyclj/s

(spy x)
source

synchronizecljs

(synchronize f)

Returns a fn that will queue calls to f, an async fn.

Returns a fn that will queue calls to `f`, an async fn.
sourceraw docstring

take-strclj/s

(take-str n s)
source

textclj/smacro

(text & forms)

Generates a string from pairs of conditions and lines of text.

The right-hand side values will be flattened, so you can give strings, collections of strings, or nested collections of strings. nils are removed.

Example:

(println (text
           true  ["foo" nil "bar"]
           false "baz"
           true  "quux"))
foo
bar
quux
Generates a string from pairs of conditions and lines of text.

The right-hand side values will be flattened, so you can give strings,
collections of strings, or nested collections of strings. `nil`s are
removed.

Example:
```
(println (text
           true  ["foo" nil "bar"]
           false "baz"
           true  "quux"))
foo
bar
quux
```
sourceraw docstring

to-chancljs

(to-chan p)

Converts a js promise to a channel. If the promise throws an error, logs to the console and closes the channel.

Converts a js promise to a channel.
If the promise throws an error, logs to the console and closes the channel.
sourceraw docstring

when-some-allclj/smacro

(when-some-all [& bindings] & forms)
source (clj)source (cljs)

wrandclj/s

(wrand slices)
source

wrap-firebase-fncljs

(wrap-firebase-fn handler)
source

wrap-vecclj/s

(wrap-vec x)

Use judiciously.

Use judiciously.
sourceraw docstring

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

× close