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

captureclj/smacro

(capture & xs)
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

condas->clj/smacro

(condas-> expr name & clauses)

Combination of cond-> and as->.

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

defconfigclj/smacro

(defconfig default)

Defines config and init-config! vars.

Example:

(defconfig
  {:first-name "John"
   :last-name  "Doe"
   :full-name ^:derived #(str (:first-name %) " " (:last-name %))})

config
=> {:first-name "John" :last-name  "Doe" :full-name "John Doe"}

(init-config! {:first-name "Jane"})
config
=> {:first-name "Jane" :last-name  "Doe" :full-name "Jane Doe"}

default is a map. 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.

init-config! takes any number of maps and merges them onto the provided config map using taoensso.encore/nested-merge, deriving values afterward.

Defines `config` and `init-config!` vars.

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

config
=> {:first-name "John" :last-name  "Doe" :full-name "John Doe"}

(init-config! {:first-name "Jane"})
config
=> {:first-name "Jane" :last-name  "Doe" :full-name "Jane Doe"}
```
`default` is a map. 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.

`init-config!` takes any number of maps and merges them onto the provided config
map using `taoensso.encore/nested-merge`, deriving values afterward.
sourceraw docstring

derive-configclj/s

(derive-config m)

Replaces any ^:derived values in m. See defconfig.

Replaces any `^:derived` values in `m`. See [[defconfig]].
sourceraw docstring

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

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

forvclj/smacro

(forv & body)
source

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

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

map-kvclj/s

(map-kv f m)
source

padclj/s

(pad n _val coll)
source

parse-intclj/s

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

pprintclj/s

source

pred->clj/s

(pred-> x f g)
source

rand-strclj/s

(rand-str len)
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

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

× close